Message ID | 153616292366.23468.14988166998690800938.stgit@warthog.procyon.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/11] UAPI: drm: Fix use of C++ keywords as structural members | expand |
On Wed, Sep 05, 2018 at 04:55:23PM +0100, David Howells wrote: > nilfs_checkpoint_set_##name(struct nilfs_checkpoint *cp) \ > { \ > - cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) | \ > + cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) | \ > (1UL << NILFS_CHECKPOINT_##flag)); \ How about sanitiziung the damn thing to cp->cp_flags |= __cpu_to_le32(1UL << NILFS_CHECKPOINT_##flag)); while you are at it? Or, perhaps, even #define NILFS2_CP_FLAG(flag) __cpu_to_le32(1UL << NILFS_CHECKPOINT_##flag) and cp->cp_flags |= NILFS2_CP_FLAG(flag) for this one, > } \ > static inline void \ > nilfs_checkpoint_clear_##name(struct nilfs_checkpoint *cp) \ > { \ > - cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) & \ > + cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) & \ > ~(1UL << NILFS_CHECKPOINT_##flag)); \ cp->cp_flags &= ~NILFS2_CP_FLAG(flag); here > } \ > static inline int \ > nilfs_checkpoint_##name(const struct nilfs_checkpoint *cp) \ > { \ > - return !!(le32_to_cpu(cp->cp_flags) & \ > + return !!(__le32_to_cpu(cp->cp_flags) & \ > (1UL << NILFS_CHECKPOINT_##flag)); \ and !!(cp->cp_flags & NILFS2_CP_FLAG(flag) here? Or maybe even make the damn thing bool and lose the !! here... )> } > and similar for those: > @@ -595,20 +596,20 @@ enum { > static inline void \ > nilfs_segment_usage_set_##name(struct nilfs_segment_usage *su) \ > { \ > - su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) | \ > + su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) | \ > (1UL << NILFS_SEGMENT_USAGE_##flag));\ > } \ > static inline void \ > nilfs_segment_usage_clear_##name(struct nilfs_segment_usage *su) \ > { \ > su->su_flags = \ > - cpu_to_le32(le32_to_cpu(su->su_flags) & \ > + __cpu_to_le32(__le32_to_cpu(su->su_flags) & \ > ~(1UL << NILFS_SEGMENT_USAGE_##flag)); \ > } \ > static inline int \ > nilfs_segment_usage_##name(const struct nilfs_segment_usage *su) \ > { \ > - return !!(le32_to_cpu(su->su_flags) & \ > + return !!(__le32_to_cpu(su->su_flags) & \ > (1UL << NILFS_SEGMENT_USAGE_##flag)); \ > } > @@ -619,15 +620,15 @@ NILFS_SEGMENT_USAGE_FNS(ERROR, error) > static inline void > nilfs_segment_usage_set_clean(struct nilfs_segment_usage *su) > { > - su->su_lastmod = cpu_to_le64(0); > - su->su_nblocks = cpu_to_le32(0); > - su->su_flags = cpu_to_le32(0); > + su->su_lastmod = __cpu_to_le64(0); > + su->su_nblocks = __cpu_to_le32(0); > + su->su_flags = __cpu_to_le32(0); > } > > static inline int > nilfs_segment_usage_clean(const struct nilfs_segment_usage *su) > { > - return !le32_to_cpu(su->su_flags); > + return !__le32_to_cpu(su->su_flags); "Check that after byteswap it becomes 0", is it? How is that different from return !su->su_flags; ?
diff --git a/include/uapi/linux/nilfs2_ondisk.h b/include/uapi/linux/nilfs2_ondisk.h index a7e66ab11d1d..d3bd2fe08791 100644 --- a/include/uapi/linux/nilfs2_ondisk.h +++ b/include/uapi/linux/nilfs2_ondisk.h @@ -29,6 +29,7 @@ #include <linux/types.h> #include <linux/magic.h> +#include <asm/byteorder.h> #define NILFS_INODE_BMAP_SIZE 7 @@ -533,19 +534,19 @@ enum { static inline void \ nilfs_checkpoint_set_##name(struct nilfs_checkpoint *cp) \ { \ - cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) | \ + cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) | \ (1UL << NILFS_CHECKPOINT_##flag)); \ } \ static inline void \ nilfs_checkpoint_clear_##name(struct nilfs_checkpoint *cp) \ { \ - cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) & \ + cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) & \ ~(1UL << NILFS_CHECKPOINT_##flag)); \ } \ static inline int \ nilfs_checkpoint_##name(const struct nilfs_checkpoint *cp) \ { \ - return !!(le32_to_cpu(cp->cp_flags) & \ + return !!(__le32_to_cpu(cp->cp_flags) & \ (1UL << NILFS_CHECKPOINT_##flag)); \ } @@ -595,20 +596,20 @@ enum { static inline void \ nilfs_segment_usage_set_##name(struct nilfs_segment_usage *su) \ { \ - su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) | \ + su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) | \ (1UL << NILFS_SEGMENT_USAGE_##flag));\ } \ static inline void \ nilfs_segment_usage_clear_##name(struct nilfs_segment_usage *su) \ { \ su->su_flags = \ - cpu_to_le32(le32_to_cpu(su->su_flags) & \ + __cpu_to_le32(__le32_to_cpu(su->su_flags) & \ ~(1UL << NILFS_SEGMENT_USAGE_##flag)); \ } \ static inline int \ nilfs_segment_usage_##name(const struct nilfs_segment_usage *su) \ { \ - return !!(le32_to_cpu(su->su_flags) & \ + return !!(__le32_to_cpu(su->su_flags) & \ (1UL << NILFS_SEGMENT_USAGE_##flag)); \ } @@ -619,15 +620,15 @@ NILFS_SEGMENT_USAGE_FNS(ERROR, error) static inline void nilfs_segment_usage_set_clean(struct nilfs_segment_usage *su) { - su->su_lastmod = cpu_to_le64(0); - su->su_nblocks = cpu_to_le32(0); - su->su_flags = cpu_to_le32(0); + su->su_lastmod = __cpu_to_le64(0); + su->su_nblocks = __cpu_to_le32(0); + su->su_flags = __cpu_to_le32(0); } static inline int nilfs_segment_usage_clean(const struct nilfs_segment_usage *su) { - return !le32_to_cpu(su->su_flags); + return !__le32_to_cpu(su->su_flags); } /**
nilfs2 exports a load of inline functions to userspace that call kernel byteswapping functions that don't exist in UAPI. Fix this by making it #include asm/byteorder.h and use the functions declared there. A better way is probably to remove these inline functions from the nilfs2 header since they are technically broken. Signed-off-by: David Howells <dhowells@redhat.com> cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> cc: linux-nilfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- include/uapi/linux/nilfs2_ondisk.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)