]> wimlib.net Git - wimlib/commitdiff
mount_image.c: Use well-defined check in flags_writable()
authorEric Biggers <ebiggers3@gmail.com>
Mon, 10 Feb 2014 00:22:35 +0000 (18:22 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 10 Feb 2014 00:24:18 +0000 (18:24 -0600)
No effect on Linux, but it's more correct to explicitly check for
the O_ACCMODE bits being O_WRONLY or O_RDWR.

src/mount_image.c

index 04be3f6f73c8e3ea9b6b87de79959921ee3302b9..586722e50fc84fb25c27f1a127583b8a4d6c4da5 100644 (file)
@@ -164,7 +164,8 @@ get_lookup_flags(const struct wimfs_context *ctx)
 static inline int
 flags_writable(int open_flags)
 {
-       return open_flags & (O_RDWR | O_WRONLY);
+       int accmode = (open_flags & O_ACCMODE);
+       return (accmode == O_RDWR || accmode == O_WRONLY);
 }
 
 /*