diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/sd-journal.c | 10 | ||||
-rw-r--r-- | src/readahead/readahead-collect.c | 2 | ||||
-rw-r--r-- | src/shared/macro.h | 7 | ||||
-rw-r--r-- | src/shared/util.c | 5 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index e021d98155..15239b5688 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1251,11 +1251,11 @@ static void check_network(sd_journal *j, int fd) { return; j->on_network = - sfs.f_type == (__SWORD_TYPE) CIFS_MAGIC_NUMBER || - sfs.f_type == (__SWORD_TYPE) CODA_SUPER_MAGIC || - sfs.f_type == (__SWORD_TYPE) NCP_SUPER_MAGIC || - sfs.f_type == (__SWORD_TYPE) NFS_SUPER_MAGIC || - sfs.f_type == (__SWORD_TYPE) SMB_SUPER_MAGIC; + F_TYPE_CMP(sfs.f_type, CIFS_MAGIC_NUMBER) || + F_TYPE_CMP(sfs.f_type, CODA_SUPER_MAGIC) || + F_TYPE_CMP(sfs.f_type, NCP_SUPER_MAGIC) || + F_TYPE_CMP(sfs.f_type, NFS_SUPER_MAGIC) || + F_TYPE_CMP(sfs.f_type, SMB_SUPER_MAGIC); } static int add_file(sd_journal *j, const char *prefix, const char *filename) { diff --git a/src/readahead/readahead-collect.c b/src/readahead/readahead-collect.c index 02ecbe56c9..75ec5b70c7 100644 --- a/src/readahead/readahead-collect.c +++ b/src/readahead/readahead-collect.c @@ -505,7 +505,7 @@ done: on_ssd = fs_on_ssd(root) > 0; log_debug("On SSD: %s", yes_no(on_ssd)); - on_btrfs = statfs(root, &sfs) >= 0 && sfs.f_type == (__SWORD_TYPE) BTRFS_SUPER_MAGIC; + on_btrfs = statfs(root, &sfs) >= 0 && F_TYPE_CMP(sfs.f_type, BTRFS_SUPER_MAGIC); log_debug("On btrfs: %s", yes_no(on_btrfs)); if (asprintf(&pack_fn_new, "%s/.readahead.new", root) < 0) { 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) { |