Re: [PATCH] ext3: Fix sparse -Wbitwise warnings.
From: Stephen C. Tweedie
Date: Tue Feb 15 2005 - 09:15:08 EST
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/