tdb: Simplify fcntl_lock() a bit
authorVolker Lendecke <vl@samba.org>
Sat, 16 Feb 2013 13:17:57 +0000 (14:17 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 19 Feb 2013 14:46:45 +0000 (15:46 +0100)
All arguments but the cmd are the same. To me this looks a bit better
and saves some bytes in the object code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tdb/common/lock.c

index dadc69e8cdfd2cd85b0d3ed9a9f57f1bf75d1d65..16963df097c852ebc7411cde133d84fe685546a8 100644 (file)
@@ -36,6 +36,7 @@ static int fcntl_lock(struct tdb_context *tdb,
                      int rw, off_t off, off_t len, bool waitflag)
 {
        struct flock fl;
+       int cmd;
 
        fl.l_type = rw;
        fl.l_whence = SEEK_SET;
@@ -43,10 +44,9 @@ static int fcntl_lock(struct tdb_context *tdb,
        fl.l_len = len;
        fl.l_pid = 0;
 
-       if (waitflag)
-               return fcntl(tdb->fd, F_SETLKW, &fl);
-       else
-               return fcntl(tdb->fd, F_SETLK, &fl);
+       cmd = waitflag ? F_SETLKW : F_SETLK;
+
+       return fcntl(tdb->fd, cmd, &fl);
 }
 
 static int fcntl_unlock(struct tdb_context *tdb, int rw, off_t off, off_t len)