xfs
[Top] [All Lists]

Re: [PATCH v2 05/17] xfs: create macros/helpers for dealing with sparse

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH v2 05/17] xfs: create macros/helpers for dealing with sparse inode chunks
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 4 Nov 2014 07:15:07 -0500
Cc: Fanael Linithien <fanael4@xxxxxxxxx>, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20141104013308.GC23575@dastard>
References: <1415031146-9107-1-git-send-email-bfoster@xxxxxxxxxx> <1415031146-9107-6-git-send-email-bfoster@xxxxxxxxxx> <CA+o=1OWm3XWUgNXR1_CravnEBL8fD8dwyMvY4CN9rbAsw0Q4Sw@xxxxxxxxxxxxxx> <20141103223407.GA14732@xxxxxxxxxxxxxxx> <CA+o=1OWy=VSo3XYMd9LuxiqzRp=p+5iJ909uoJzgKYdOOyVcvg@xxxxxxxxxxxxxx> <20141104013308.GC23575@dastard>
User-agent: Mutt/1.5.23 (2014-03-12)
On Tue, Nov 04, 2014 at 12:33:08PM +1100, Dave Chinner wrote:
> On Tue, Nov 04, 2014 at 12:56:17AM +0100, Fanael Linithien wrote:
> > 2014-11-03 23:34 GMT+01:00 Brian Foster <bfoster@xxxxxxxxxx>:
> > > On Mon, Nov 03, 2014 at 11:12:12PM +0100, Fanael Linithien wrote:
> > >> 2014-11-03 17:12 GMT+01:00 Brian Foster <bfoster@xxxxxxxxxx>:
> > >> >
> > >> > +static inline bool xfs_inobt_issparse(uint16_t holemask)
> > >> > +{
> > >> > +       return holemask == 0 ? false : true;
> > >> > +}
> > >>
> > >> Surely that should be "return holemask != 0;"?
> > >>
> > >
> > > ir_holemask bits are set for holes in the inode chunk and unset for
> > > allocated regions. This means that ir_holemask == 0 for a normal,
> > > fully-allocated chunk and != 0 otherwise (some bits are set to indicate
> > > the chunk has a hole). Check out the commit log for patch 4 for
> > > reasoning.
> > 
> > Oh, I don't comment on the logic, as I don't really know much about
> > XFS code. It's purely a stylistic suggestion: "holemask == 0 ? false :
> > true" looks entirely equivalent to "holemask != 0".
> 
> Even that is unnecessary. booleans are handled by the
> compiler quite nicely - just casting a bool
> type will give the same result. i.e. (bool)holemask results in a
> value of "false" if holemask is zero, "true" if holemask has any
> value other than zero.
> 
> static inline bool xfs_inobt_issparse(uint16_t holemask)
> {
>        return holemask;
> }
> 
> Will give the desired result as there is an implicit typecast to
> bool in that return statement.....
> 

Indeed, thanks.

Brian

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>