mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu
To: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Eric Paris <eparis@redhat.com>, Jan Kara <jack@suse.cz>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1 v2] fanotify: check file flags passed in fanotify_init
Date: Tue, 13 May 2014 18:38:44 -0400	[thread overview]
Message-ID: <77399.1400020724@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Tue, 13 May 2014 19:34:33 +0200." <537257A9.3070504@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

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;

[-- Attachment #2: Type: application/pgp-signature, Size: 848 bytes --]

  reply	other threads:[~2014-05-13 22:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 19:02 Heinrich Schuchardt
2014-05-13  8:25 ` Michael Kerrisk (man-pages)
2014-05-13 17:16   ` Heinrich Schuchardt
2014-05-13 17:34     ` Michael Kerrisk (man-pages)
2014-05-13 22:38       ` Valdis.Kletnieks [this message]
2014-05-14 21:17 ` Jan Kara
2014-05-14 21:28   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77399.1400020724@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=eparis@redhat.com \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®