Fix incorrect access mode check
authorChengwei Yang <chengwei.yang@intel.com>
Mon, 5 Nov 2012 04:25:41 +0000 (12:25 +0800)
committerChengwei Yang <chengwei.yang@intel.com>
Mon, 5 Nov 2012 04:27:49 +0000 (12:27 +0800)
The O_* variales are integers and aren't not suitable with bit
operation, because O_RDONLY is 0, so if the mode is O_RDONLY, (mode &
O_RDONLY) always return false. So the access mode is always 0,
that means F_OK rather than R_OK.

Change-Id: If750f85864d32f7d0a039b2ee114ef133a311434
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
logutil.c

index 671efee..d9d369f 100755 (executable)
--- a/logutil.c
+++ b/logutil.c
@@ -661,8 +661,8 @@ int main(int argc, char **argv)
         g_dev_count = 1;
 
         int accessmode =
-                  (mode & O_RDONLY) ? R_OK : 0
-                | (mode & O_WRONLY) ? W_OK : 0;
+                  (mode == O_RDONLY) ? R_OK : 0
+                | (mode == O_WRONLY) ? W_OK : 0;
 
        // only add this if it's available
        if (0 == access("/dev/"LOGGER_LOG_SYSTEM, accessmode)) {