Skip to contentSkip to conversation

libfsimage: fix clang 10 build

PATCH In review Roger Pau Monne 2 participants 3 messages Mar 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libfsimage: fix clang 10 build

clang complains with:

fsys_zfs.c:826:2: error: converting the enum constant to a boolean [-Werror,-Wint-in-bool-context]

        VERIFY_DN_TYPE(dn, DMU_OT_PLAIN_FILE_CONTENTS);
        ^
/wrkdirs/usr/ports/sysutils/xen-tools/work/xen-4.13.0/tools/libfsimage/zfs/../../../tools/libfsimage/zfs/fsys_zfs.h:74:11: note: expanded from macro 'VERIFY_DN_TYPE'
        if (type && (dnp)->dn_type != type) { \
                 ^

1 error generated.

Fix this by not forcing an implicit conversion of the enum into a boolean and instead comparing with the 0 enumerator.

---
 tools/libfsimage/zfs/fsys_zfs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libfsimage/zfs/fsys_zfs.h +2 -2
index 5cd627dbac..721972a05a 100644
@@ -71,7 +71,7 @@ typedef	unsigned int size_t;
  * Can only be used in functions returning non-0 for failure.
  */
 #define	VERIFY_DN_TYPE(dnp, type) \
-	if (type && (dnp)->dn_type != type) { \
+	if (type != DMU_OT_NONE && (dnp)->dn_type != type) { \
 		return (ERR_FSYS_CORRUPT); \
 	}
 
@@ -80,7 +80,7 @@ typedef	unsigned int size_t;
  * Can only be used in functions returning 0 for failure.
  */
 #define	VERIFY_OS_TYPE(osp, type) \
-	if (type && (osp)->os_type != type) { \
+	if (type != DMU_OST_NONE && (osp)->os_type != type) { \
 		errnum = ERR_FSYS_CORRUPT; \
 		return (0); \
 	}
Signature · 7 lines
2.25.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 2/2 libfsimage: fix parentheses in macro parameters

VERIFY_DN_TYPE and VERIFY_OS_TYPE should use parentheses when accessing the type parameter. Note that none of the current usages require this, it's just done for correctness.

---
 tools/libfsimage/zfs/fsys_zfs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libfsimage/zfs/fsys_zfs.h +2 -2
index 721972a05a..b4be51b50d 100644
@@ -71,7 +71,7 @@ typedef	unsigned int size_t;
  * Can only be used in functions returning non-0 for failure.
  */
 #define	VERIFY_DN_TYPE(dnp, type) \
-	if (type != DMU_OT_NONE && (dnp)->dn_type != type) { \
+	if ((type) != DMU_OT_NONE && (dnp)->dn_type != (type)) { \
 		return (ERR_FSYS_CORRUPT); \
 	}
 
@@ -80,7 +80,7 @@ typedef	unsigned int size_t;
  * Can only be used in functions returning 0 for failure.
  */
 #define	VERIFY_OS_TYPE(osp, type) \
-	if (type != DMU_OST_NONE && (osp)->os_type != type) { \
+	if ((type) != DMU_OST_NONE && (osp)->os_type != (type)) { \
 		errnum = ERR_FSYS_CORRUPT; \
 		return (0); \
 	}
Signature · 7 lines
2.25.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/2
#2 lore raw
In reply to Roger Pau Monne
Quoted 8 lines · Roger Pau Monne

clang complains with:

fsys_zfs.c:826:2: error: converting the enum constant to a boolean [-Werror,-Wint-in-bool-context]

        VERIFY_DN_TYPE(dn, DMU_OT_PLAIN_FILE_CONTENTS);
        ^
/wrkdirs/usr/ports/sysutils/xen-tools/work/xen-4.13.0/tools/libfsimage/zfs/../../../tools/libfsimage/zfs/fsys_zfs.h:74:11: note: expanded from macro 'VERIFY_DN_TYPE'
        if (type && (dnp)->dn_type != type) { \
                 ^
Quoted 6 lines

1 error generated.

Fix this by not forcing an implicit conversion of the enum into a boolean and instead comparing with the 0 enumerator.

Both patches:

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel