chiark / gitweb /
journal, shared: fix warnings during compilation on 32 bits
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Nov 2012 16:17:21 +0000 (17:17 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Nov 2012 22:26:44 +0000 (23:26 +0100)
Some filesystem magics are too big to fit in 31 bits,
and are wrapped to negative. f_type is an int on 32 bits, so
it is signed, and we get a warning on comparison.

src/journal/catalog.c
src/journal/sd-journal.c
src/shared/util.c

index 22029da8518893ef0197e5bfc489addf49a0598c..2812d5970b0ef5ac9734dc5e7bd0759f5fe24933 100644 (file)
@@ -384,7 +384,7 @@ int catalog_update(void) {
                 goto finish;
         }
 
-        log_debug("%s: wrote %u items, with %zu bytes of strings, %zu total size.",
+        log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
                  CATALOG_DATABASE, n, sb->len, ftell(w));
 
         free(p);
index c86f1eaab15c957daac409bee1ff07ae18521b1b..41f0c4dfb4bc677ae57df8b50bc2b60b5057bb1f 100644 (file)
@@ -1205,7 +1205,7 @@ static void check_network(sd_journal *j, int fd) {
                 return;
 
         j->on_network =
-                sfs.f_type == CIFS_MAGIC_NUMBER ||
+                (long)sfs.f_type == (long)CIFS_MAGIC_NUMBER ||
                 sfs.f_type == CODA_SUPER_MAGIC ||
                 sfs.f_type == NCP_SUPER_MAGIC ||
                 sfs.f_type == NFS_SUPER_MAGIC ||
index 6d826b6f5eafbf185bc0191d850a176ff3aff6a3..4cf928f83a3049a443e1cb5bf9404914ed7e2a06 100644 (file)
@@ -3400,6 +3400,12 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
         return ret;
 }
 
+static int is_temporary_fs(struct statfs *s) {
+        assert(s);
+        return s->f_type == TMPFS_MAGIC ||
+                (long)s->f_type == (long)RAMFS_MAGIC;
+}
+
 int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) {
         struct statfs s;
 
@@ -3413,9 +3419,7 @@ int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root
         /* We refuse to clean disk file systems with this call. This
          * is extra paranoia just to be sure we never ever remove
          * non-state data */
-
-        if (s.f_type != TMPFS_MAGIC &&
-            s.f_type != RAMFS_MAGIC) {
+        if (!is_temporary_fs(&s)) {
                 log_error("Attempted to remove disk file system, and we can't allow that.");
                 close_nointr_nofail(fd);
                 return -EPERM;
@@ -3448,8 +3452,7 @@ static int rm_rf_internal(const char *path, bool only_dirs, bool delete_root, bo
                         if (statfs(path, &s) < 0)
                                 return -errno;
 
-                        if (s.f_type != TMPFS_MAGIC &&
-                            s.f_type != RAMFS_MAGIC) {
+                        if (!is_temporary_fs(&s)) {
                                 log_error("Attempted to remove disk file system, and we can't allow that.");
                                 return -EPERM;
                         }
@@ -3468,8 +3471,7 @@ static int rm_rf_internal(const char *path, bool only_dirs, bool delete_root, bo
                         return -errno;
                 }
 
-                if (s.f_type != TMPFS_MAGIC &&
-                    s.f_type != RAMFS_MAGIC) {
+                if (!is_temporary_fs(&s)) {
                         log_error("Attempted to remove disk file system, and we can't allow that.");
                         close_nointr_nofail(fd);
                         return -EPERM;
@@ -5767,7 +5769,7 @@ bool in_initrd(void) {
 
         saved = access("/etc/initrd-release", F_OK) >= 0 &&
                 statfs("/", &s) >= 0 &&
-                (s.f_type == TMPFS_MAGIC || s.f_type == RAMFS_MAGIC);
+                is_temporary_fs(&s);
 
         return saved;
 }