lkml.org 
[lkml]   [2014]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/1 v2] fanotify: check file flags passed in fanotify_init
From
Date
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]
\
 
 \ /
  Last update: 2014-05-14 01:21    [W:0.054 / U:0.888 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site