]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
login: Remove double-assignment of fl.l_whence in try_file_lock
authorFlorian Weimer <fweimer@redhat.com>
Thu, 7 Nov 2019 08:53:41 +0000 (09:53 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 7 Nov 2019 08:54:33 +0000 (09:54 +0100)
Since l_whence is the second member of struct flock, it is written
twice.  The double-assignment is technically undefined behavior due to
the lack of a sequence point.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Change-Id: I2baf9e70690e723c61051b25ccbd510aec15976c

login/utmp_file.c

index be7cc0671b1b41cbe56ad3c7063bd190bc97d913..e6272334781ce51337c2e910460b7717c5458c23 100644 (file)
@@ -79,7 +79,7 @@ try_file_lock (int fd, int type)
  struct flock64 fl =
    {
     .l_type = type,
-    fl.l_whence = SEEK_SET,
+    .l_whence = SEEK_SET,
    };
 
  bool status = __fcntl64_nocancel (fd, F_SETLKW, &fl) < 0;