summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/macro.h7
-rw-r--r--src/shared/util.c5
2 files changed, 10 insertions, 2 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 9bf81dc3cc..ac61b49588 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -264,6 +264,13 @@ do { \
} \
} while(false)
+ /* Because statfs.t_type can be int on some architecures, we have to cast
+ * the const magic to the type, otherwise the compiler warns about
+ * signed/unsigned comparison, because the magic can be 32 bit unsigned.
+ */
+#define F_TYPE_CMP(a, b) (a == (typeof(a)) b)
+
+
/* Returns the number of chars needed to format variables of the
* specified type as a decimal string. Adds in extra space for a
* negative '-' prefix. */
diff --git a/src/shared/util.c b/src/shared/util.c
index 5d03272619..1fc6c5aa1a 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2779,8 +2779,9 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
static int is_temporary_fs(struct statfs *s) {
assert(s);
- return s->f_type == (__SWORD_TYPE) TMPFS_MAGIC ||
- s->f_type == (__SWORD_TYPE) RAMFS_MAGIC;
+ return
+ F_TYPE_CMP(s->f_type, TMPFS_MAGIC) ||
+ F_TYPE_CMP(s->f_type, RAMFS_MAGIC);
}
int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) {