public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Brian Foster <bfoster@redhat.com>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH v6 1/3] xfs: fix the size of xfs_mode_to_ftype table
Date: Mon, 9 Jan 2017 13:17:49 -0800	[thread overview]
Message-ID: <20170109211749.GC14038@birch.djwong.org> (raw)
In-Reply-To: <CAOQ4uxi4AWSN89MtZH6f0B9aC_AMmC6bxbUCAh9LMU4G+Z9U1A@mail.gmail.com>

On Mon, Jan 09, 2017 at 07:21:25PM +0200, Amir Goldstein wrote:
> On Mon, Jan 9, 2017 at 5:51 PM, Christoph Hellwig <hch@infradead.org> wrote:
> > On Mon, Jan 09, 2017 at 03:06:27PM +0200, Amir Goldstein wrote:
> >> Fix the size of the xfs_mode_to_ftype conversion table,
> >> which was too small to handle an invalid value of mode=S_IFMT.
> >>
> >> Use a convenience macro S_DT(mode) to convert from
> >> mode to dirent file type and change the name of the table
> >> to xfs_dtype_to_ftype to correctly describe its index values.
> >
> > This looks like an awful lot of magic.  Would a switch statement
> > generate so much worse code?
> 
> I doubt it really matters that much, so it's down to a matter of taste.
> I personally like the existing map table better than switch if anyone cares ;-)
> but I think that the strongest argument in favor of the existing code
> is that it works, so no reason to change it.
> IMHO, this minor fix and cleanup do not justify switching the code over to
> switch statement.

I can't feed a garbage index to a switch statement and have it fly
off the end of an array; plus we can throw asserts in a default: case.

--D

> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-01-09 21:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 13:06 [PATCH v6 0/3] xfs: fixes for malformed on-disk i_mode Amir Goldstein
2017-01-09 13:06 ` [PATCH v6 1/3] xfs: fix the size of xfs_mode_to_ftype table Amir Goldstein
2017-01-09 15:51   ` Christoph Hellwig
2017-01-09 17:21     ` Amir Goldstein
2017-01-09 21:17       ` Darrick J. Wong [this message]
2017-01-10  7:54         ` Amir Goldstein
2017-01-09 13:06 ` [PATCH v6 2/3] xfs: sanity check directory inode di_size Amir Goldstein
2017-01-09 15:52   ` Christoph Hellwig
2017-01-09 13:06 ` [PATCH v6 3/3] xfs: make the ASSERT() condition likely Amir Goldstein
2017-01-09 15:53   ` Christoph Hellwig

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=20170109211749.GC14038@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=bfoster@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    /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