Skip to contentSkip to conversation

libgfs2: Add __force tags to endianness conversion macros

PATCH New Andrew Price 1 participant 1 message Apr 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libgfs2: Add __force tags to endianness conversion macros

The __be* on-disk field types are annotated with __bitwise, which causes sparse to recognise them as conflicting with non-__bitwise types, but the endianness conversion macros don't have the required annotations to tell sparse when to resolve the conflicts instead of flagging a warning. Add __force annotations to the conversion macros.

This clears up a handful of sparse warnings but the anti-pattern of storing cpu-endian values in the on-disk structs is still common (see libgfs2/ondisk.c), so there are still some to be resolved.

---
 gfs2/convert/gfs2_convert.c |  2 +-
 gfs2/include/linux/types.h  |  3 +++
 gfs2/libgfs2/libgfs2.h      | 49 ++++++++++++++++++-------------------
 3 files changed, 28 insertions(+), 26 deletions(-)
gfs2/convert/gfs2_convert.c +1 -1
index 5656b39d..ded2589e 100644
@@ -1201,7 +1201,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
 		/* Only do this if the dent was a true gfs1 dent, and not a   */
 		/* gfs2 dent converted from a previously aborted run.         */
 		if (dent_was_gfs1) {
-			switch be16_to_cpu(dent->de_type) {
+			switch (be16_to_cpu(dent->de_type)) {
 			case GFS_FILE_NON:
 				dent->de_type = cpu_to_be16(DT_UNKNOWN);
 				break;
gfs2/include/linux/types.h +3 -0
index 7f4d4b98..a092afc0 100644
@@ -7,10 +7,13 @@
 
 #ifdef __CHECKER__
 #define __bitwise__ __attribute__((bitwise))
+#define __force__ __attribute__((force))
 #else
 #define __bitwise__
+#define __force__
 #endif
 #define __bitwise __bitwise__
+#define __force __force__
 
 typedef uint8_t __u8;
 typedef uint16_t __u16;
gfs2/libgfs2/libgfs2.h +24 -25

66 lines not on this page · raw message

Signature · 1 line
2.30.2