[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH] ext3: Fix sparse -Wbitwise warnings.



Hi,

On Tue, 2005-02-15 at 10:46, Alexey Dobriyan wrote:

> -			if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
> -					~EXT3_FEATURE_RO_COMPAT_SUPP))) {
> +			if ((ret = le32_to_cpu(EXT3_HAS_RO_COMPAT_FEATURE(sb,
> +					~EXT3_FEATURE_RO_COMPAT_SUPP)))) {

NAK.

EXT3_HAS_RO_COMPAT_FEATURE returns a boolean value.  It happens to be
implemented internally as 

#define EXT3_HAS_COMPAT_FEATURE(sb,mask)			\
	( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )


so the compiler, looking at the preprocessed code, will reasonably
assume it's a genuine little-endian value.  But it's only used as a
boolean, so we shouldn't be requiring the callers to provide an
le32_to_cpu() conversion.

If we want to fix this, let's fix the macros: for example, convert
EXT3_HAS_COMPAT_FEATURE to be

	( le32_to_cpu(EXT3_SB(sb)->s_es->s_feature_compat) & (mask) )

so that we're doing the tests in native CPU endian-ness.

--Stephen


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]