Messages in this thread | | | Subject | Re: [PATCH 1/1 v2] fanotify: check file flags passed in fanotify_init | From | Valdis.Kletnieks@vt ... | Date | Tue, 13 May 2014 18:38:44 -0400 |
| |
On Tue, 13 May 2014 19:34:33 +0200, "Michael Kerrisk (man-pages)" said:
> >> The 'switch' could just be replaced by: > >> > >> if ((event_f_flags & O_ACCMODE) == 3) > >> return -EINVAL; > >> > >> (But I'm not sure if some might prefer the idiom you have used.) > >> > >> Cheers, > >> > >> Michael > > > > Using explicit numbers makes the code hard to read and analyze. > > I do not intend to participate in the Obfuscated C Code Contest. > > I agree that using explicit numbers is odd, but '3" in this > context does have a special meaning (see open(2)), and it struck > me as a more efficient way of doing the check. But, if others > are fine with what you've written, I have no real problem with it.
I'd be OK with the '== 3' version if there was a comment about the reserved access mode like:
/* reserved ioctl-only mode, so no fanotify for you */ if ((event_f_flags & O_ACCMODE) == 3) return -EINVAL; [unhandled content-type:application/pgp-signature] | |