s3: Slightly simplify calculate_open_access_flags
authorVolker Lendecke <vl@samba.org>
Tue, 4 Sep 2012 07:28:26 +0000 (09:28 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 26 Sep 2012 14:29:28 +0000 (16:29 +0200)
source3/smbd/open.c

index 8c24ef9ff108ab51b66ac2ff4f6ff49dd022a2bc..1f9a372dfb679476ebda5db5e8c1a0193788f3a8 100644 (file)
@@ -1873,8 +1873,7 @@ static int calculate_open_access_flags(uint32_t access_mask,
                                       int oplock_request,
                                       uint32_t private_flags)
 {
-       int flags;
-       bool need_write;
+       bool need_write, need_read;
 
        /*
         * Note that we ignore the append flag as append does not
@@ -1892,14 +1891,16 @@ static int calculate_open_access_flags(uint32_t access_mask,
        /* DENY_DOS opens are always underlying read-write on the
           file handle, no matter what the requested access mask
           says. */
-       if ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
-           access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|
-                          FILE_READ_EA|FILE_EXECUTE)) {
-               flags = O_RDWR;
-       } else {
-               flags = O_WRONLY;
+
+       need_read =
+               ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
+                access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|
+                               FILE_READ_EA|FILE_EXECUTE));
+
+       if (!need_read) {
+               return O_WRONLY;
        }
-       return flags;
+       return O_RDWR;
 }
 
 /****************************************************************************