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

index 2785d6f3d1892e71d39a954f32f43f59b72ae7dd..8c24ef9ff108ab51b66ac2ff4f6ff49dd022a2bc 100644 (file)
@@ -1874,26 +1874,30 @@ static int calculate_open_access_flags(uint32_t access_mask,
                                       uint32_t private_flags)
 {
        int flags;
+       bool need_write;
 
        /*
         * Note that we ignore the append flag as append does not
         * mean the same thing under DOS and Unix.
         */
 
-       if ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ||
-           (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE)) {
-               /* 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_write =
+               ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ||
+                (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE));
+
+       if (!need_write) {
+               return O_RDONLY;
+       }
+
+       /* 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_RDONLY;
+               flags = O_WRONLY;
        }
        return flags;
 }