[sbuild] Order of "struct flock" members is not assumed.
authorPetr Salinger <Petr.Salinger@seznam.cz>
Sun, 29 Jun 2008 15:43:37 +0000 (16:43 +0100)
committerRoger Leigh <rleigh@debian.org>
Sun, 29 Jun 2008 15:43:37 +0000 (16:43 +0100)
sbuild/sbuild-lock.cc: Initialise struct members separately, for
GNU/kFreeBSD portability.

Thanks to Petr Salinger.
Closes: #485637.

Signed-off-by: Roger Leigh <rleigh@debian.org>
debian/changelog
sbuild/sbuild-lock.cc

index 1b3a31e..514b471 100644 (file)
@@ -15,8 +15,11 @@ schroot (1.2.1-1) unstable; urgency=low
     - Update vi translation (Closes: #479750).  Thanks to Clytie Siddall.
     - Add zh_CN translation (Closes: #480174).  Thanks to LI Daobing (李道兵).
     - Update zh_CN translation.  Thanks to Ji ZhengYu.
+  * sbuild/sbuild-lock.cc: Order of "struct flock" members is not assumed,
+    for GNU/kFreeBSD portability (Closes: #485637).  Thanks to Petr
+    Salinger.
 
- -- Roger Leigh <rleigh@debian.org>  Mon, 19 May 2008 23:27:21 +0100
+ -- Roger Leigh <rleigh@debian.org>  Sun, 29 Jun 2008 16:41:02 +0100
 
 schroot (1.2.0-1) unstable; urgency=low
 
index 681f53c..b61ebda 100644 (file)
@@ -163,14 +163,12 @@ file_lock::~file_lock ()
   // destructor under any circumstances.  Any error is logged.
   if (locked)
     {
-      struct flock read_lock =
-       {
-         LOCK_NONE,
-         SEEK_SET,
-         0,
-         0, // Lock entire file
-         0
-       };
+      struct flock read_lock;
+      read_lock.l_type = LOCK_NONE;
+      read_lock.l_whence = SEEK_SET;
+      read_lock.l_start = 0;
+      read_lock.l_len = 0; // Lock entire file
+      read_lock.l_pid = 0;
 
       if (fcntl(this->fd, F_SETLK, &read_lock) == -1)
        log_exception_warning(error(UNLOCK, strerror(errno)));
@@ -195,14 +193,12 @@ file_lock::set_lock (lock::type   lock_type,
 
       /* Wait on lock until interrupted by a signal if a timeout was set,
         otherwise return immediately. */
-      struct flock read_lock =
-       {
-         lock_type,
-         SEEK_SET,
-         0,
-         0, // Lock entire file
-         0
-       };
+      struct flock read_lock;
+      read_lock.l_type = lock_type;
+      read_lock.l_whence = SEEK_SET;
+      read_lock.l_start = 0;
+      read_lock.l_len = 0; // Lock entire file
+      read_lock.l_pid = 0;
 
       if (fcntl(this->fd,
                (timeout != 0) ? F_SETLKW : F_SETLK,