]> err.no Git - util-linux/commitdiff
login: fix compiler warning (int32 time() arg)
authorKarel Zak <kzak@redhat.com>
Mon, 29 Sep 2008 10:53:39 +0000 (12:53 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 12 Dec 2008 11:56:28 +0000 (12:56 +0100)
login.c: In function ‘dolastlog’:
login.c:1438  warning: passing argument 1 of ‘time’ from incompatible pointer type

Unfortunately, on-disk lastlog format is always 32bit, bits/utmp.h:

  struct lastlog
  {
  #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
     int32_t ll_time;
  #else
     __time_t ll_time;
  #endif

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index 16bbba8df3fd52115c59114fbe959614bb8d538f..1ae183cad6daf90bbc5487f4184b0830a10d5956 100644 (file)
@@ -1435,7 +1435,13 @@ dolastlog(int quiet) {
            lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);
        }
        memset((char *)&ll, 0, sizeof(ll));
-       time(&ll.ll_time);
+
+       {
+               time_t t;
+               time(&t);
+               ll.ll_time = t; /* ll_time is always 32bit */
+       }
+
        xstrncpy(ll.ll_line, tty_name, sizeof(ll.ll_line));
        if (hostname)
            xstrncpy(ll.ll_host, hostname, sizeof(ll.ll_host));