]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
getutent.3: EXAMPLES: Fix use of time(3)
authorAlejandro Colomar <alx@kernel.org>
Wed, 6 Sep 2023 23:23:11 +0000 (01:23 +0200)
committerAlejandro Colomar <alx@kernel.org>
Thu, 7 Sep 2023 00:37:42 +0000 (02:37 +0200)
time(ptr) was wrong here, because struct utmp::ut_time is a int32_t, not
a time_t.  Also, the use of time(ptr) is obsolete, and time(NULL) is
always preferred.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
man3/getutent.3

index 494b707d2b59163ccd5287d53784b099c2cadcc5..5f3d2510a46ac42564bf371677df4d9f75e3a96e 100644 (file)
@@ -327,7 +327,7 @@ main(void)
     strcpy(entry.ut_line, ttyname(STDIN_FILENO) + strlen("/dev/"));
     /* only correct for ptys named /dev/tty[pqr][0\-9a\-z] */
     strcpy(entry.ut_id, ttyname(STDIN_FILENO) + strlen("/dev/tty"));
-    time(&entry.ut_time);
+    entry.ut_time = time(NULL);
     strcpy(entry.ut_user, getpwuid(getuid())\->pw_name);
     memset(entry.ut_host, 0, UT_HOSTSIZE);
     entry.ut_addr = 0;