[systemd-devel] [PATCH] basic: fix build on architectures with small long

Helmut Grohne helmut at subdivi.de
Thu Nov 19 15:13:11 PST 2015


The assertion

    assert_cc(sizeof(statfs_f_type_t) >= sizeof(s->f_type));

can trigger on architectures where long is smaller than struct statfs'
f_type member. This includes x32. Thus fix the typedef statfs_f_type_t.
---
 src/basic/stat-util.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Please Cc me in replies.

Helmut

diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h
index 909b220..dad4b74 100644
--- a/src/basic/stat-util.h
+++ b/src/basic/stat-util.h
@@ -52,9 +52,8 @@ int path_is_os_tree(const char *path);
 int files_same(const char *filea, const char *fileb);
 
 /* The .f_type field of struct statfs is really weird defined on
- * different archs. Let's use our own type we know is sufficiently
- * larger to store the possible values. */
-typedef long statfs_f_type_t;
+ * different archs. Let's give its type a name. */
+typedef typeof(((struct statfs*)0)->f_type) statfs_f_type_t;
 
 bool is_fs_type(const struct statfs *s, statfs_f_type_t magic_value) _pure_;
 int fd_check_fstype(int fd, statfs_f_type_t magic_value);
-- 
2.6.2



More information about the systemd-devel mailing list