]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: check returns [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 27 Mar 2013 13:13:00 +0000 (14:13 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 27 Mar 2013 13:13:00 +0000 (14:13 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index 425053406a088964c865592adc4418cc19896a17..0d2c16509225b1d62169203922b994bfdcbcb2e5 100644 (file)
@@ -506,10 +506,8 @@ static void log_lastlog(struct login_context *cxt)
        if (fd < 0)
                return;
 
-       if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1) {
-               close(fd);
-               return;
-       }
+       if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
+               goto done;
 
        /*
         * Print last log message
@@ -527,7 +525,8 @@ static void log_lastlog(struct login_context *cxt)
                                printf(_("on %.*s\n"),
                                       (int)sizeof(ll.ll_line), ll.ll_line);
                }
-               lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET);
+               if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
+                       goto done;
        }
 
        memset((char *)&ll, 0, sizeof(ll));
@@ -542,7 +541,7 @@ static void log_lastlog(struct login_context *cxt)
 
        if (write_all(fd, (char *)&ll, sizeof(ll)))
                warn(_("write lastlog failed"));
-
+done:
        close(fd);
 }