Web lists-archives.com

Re: [PATCH 2/6] statfs: use << to align with fs header




On Fri, Apr 13, 2018 at 10:55:23AM -0700, Randy Dunlap wrote:
> On 04/13/2018 10:35 AM, Andreas Dilger wrote:
> > On Apr 13, 2018, at 10:11 AM, Christian Brauner <christian.brauner@xxxxxxxxxx> wrote:
> >>
> >> Consistenly use << to define ST_* constants. This also aligns them with
> >> their MS_* counterparts in fs.h
> > 
> > IMHO, using (1 << 10) makes the code harder to debug.  If you see a field
> > in a structure like 0x8354, it is non-trivial to map this to the ST_*
> > flags if they are declared in the form (1 << 10) or BIT(10).  If they are
> > declared in the form 0x100 (as they are now) then it is trivial that the
> > ST_APPEND flag is set in 0x8354, and easy to understand the other flags.
> > 
> > So, my preference would be to NOT land this or the previous patch.

All higher values are already initialized with bit-shifts for MS_*
constants starting with (1<<16) as you can see from the patch and in
fs.h:

> +#define MS_VERBOSE     (1<<15) /* War is peace. Verbosity is silence.
> +                                * MS_VERBOSE is deprecated.
> +                                */
> +#define MS_SILENT      (1<<15)
>  #define MS_POSIXACL    (1<<16) /* VFS does not apply the umask */
>  #define MS_UNBINDABLE  (1<<17) /* change to unbindable */
>  #define MS_PRIVATE     (1<<18) /* change to private */

This just makes it uniform which imho has merit on its own.

If using shifts is considered a valid counter argument because for lack
of ease to analyze struct fields then the values for MS_* flags in fs.h
should probably all be hex values.

In any case, I'm not going to bikeshed over this. The two patches can
simply be left out when applying or I can change it all over to hex
values.

Christian