summaryrefslogtreecommitdiffstats
path: root/term-utils/write.c
diff options
context:
space:
mode:
authorSami Kerola2016-05-07 00:38:11 +0200
committerSami Kerola2016-07-01 21:54:02 +0200
commit489a0fd2f55b2bb0aefeef8a9a1514cf63ea8342 (patch)
tree393859091b2f875648e8e61b4312fe45490c14cc /term-utils/write.c
parentwrite: remove pointless fileno(3) calls (diff)
downloadkernel-qcow2-util-linux-489a0fd2f55b2bb0aefeef8a9a1514cf63ea8342.tar.gz
kernel-qcow2-util-linux-489a0fd2f55b2bb0aefeef8a9a1514cf63ea8342.tar.xz
kernel-qcow2-util-linux-489a0fd2f55b2bb0aefeef8a9a1514cf63ea8342.zip
write: set atime value in term_chk() only when needed
The search_utmp() is needs atime but main() does not, so remove the later. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'term-utils/write.c')
-rw-r--r--term-utils/write.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/term-utils/write.c b/term-utils/write.c
index 03af66050..fb9cdf59b 100644
--- a/term-utils/write.c
+++ b/term-utils/write.c
@@ -104,7 +104,8 @@ static int term_chk(char *tty, int *msgsokP, time_t * atimeP, int showerror)
*msgsokP = 1;
else
*msgsokP = (s.st_mode & S_IWGRP) && (getegid() == s.st_gid);
- *atimeP = s.st_atime;
+ if (atimeP)
+ *atimeP = s.st_atime;
return 0;
}
@@ -284,7 +285,6 @@ static void do_write(char *tty, char *mytty, uid_t myuid)
int main(int argc, char **argv)
{
- time_t atime;
uid_t myuid;
int msgsok = 0, myttyfd, c;
char tty[PATH_MAX], *mytty;
@@ -333,7 +333,7 @@ int main(int argc, char **argv)
*/
if (!strncmp(mytty, "/dev/", 5))
mytty += 5;
- if (term_chk(mytty, &msgsok, &atime, 1))
+ if (term_chk(mytty, &msgsok, NULL, 1))
exit(EXIT_FAILURE);
if (!msgsok)
errx(EXIT_FAILURE,
@@ -357,7 +357,7 @@ int main(int argc, char **argv)
errx(EXIT_FAILURE,
_("%s is not logged in on %s"),
argv[1], argv[2]);
- if (term_chk(argv[2], &msgsok, &atime, 1))
+ if (term_chk(argv[2], &msgsok, NULL, 1))
exit(EXIT_FAILURE);
if (myuid && !msgsok)
errx(EXIT_FAILURE,