Re: [PATCH v6 01/24] erofs: add on-disk layout

Gao Xiang
2019-08-29T15:42:33Z

Hi Christoph,

On Thu, Aug 29, 2019 at 02:59:54AM -0700, Christoph Hellwig wrote:

[]

>
> > +static bool erofs_inode_is_data_compressed(unsigned int datamode)
> > +{
> > + if (datamode == EROFS_INODE_FLAT_COMPRESSION)
> > + return true;
> > + return datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY;
> > +}
>
> This looks like a really obsfucated way to write:
>
> return datamode == EROFS_INODE_FLAT_COMPRESSION ||
> datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY;

Add a word about this, the above approach is not horrible if more
datamode add here and comments, e.g

static bool erofs_inode_is_data_compressed(unsigned int datamode)
{
/* has z_erofs_map_header */
if (datamode == EROFS_INODE_FLAT_COMPRESSION)
return true;
/* some blablabla */
if (datamode == (1) )
return true;
/* some blablablabla */
if (datamode == (2) )
return true;
/* no z_erofs_map_header */
return datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY;
}

vs.

static bool erofs_inode_is_data_compressed(unsigned int datamode)
{
/* has z_erofs_map_header */
return datamode == EROFS_INODE_FLAT_COMPRESSION ||
/* some blablabla */
datamode == (1) ||
/* some blablablabla */
datamode == (2) ||
/* no z_erofs_map_header */
datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY;
}

I have no idea which one is better.
Anyway, if you still like the form, I will change it.

Thanks,
Gao Xiang