]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Fix some clang warnings
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 4 Apr 2017 08:28:13 +0000 (00:28 -0800)
committerKent Overstreet <kent.overstreet@gmail.com>
Tue, 4 Apr 2017 14:43:08 +0000 (06:43 -0800)
the issue in cmd_debug - passing members of struct bpos to kstrtoull,
which aren't aligned - was a legit bug

Makefile
cmd_debug.c
cmd_fs.c
include/linux/blkdev.h
include/linux/bug.h
include/linux/spinlock.h

index 0822433c9bca36075e7bc3a0fdeb54753e145ce6..e8a80c7c316246f687402163a70f99548f623678 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,6 @@
 PREFIX=/usr
 INSTALL=install
 CFLAGS+=-std=gnu99 -O2 -g -MMD -Wall                           \
-       -Wno-unused-but-set-variable                            \
        -Wno-pointer-sign                                       \
        -fno-strict-aliasing                                    \
        -I. -Iinclude -Ilibbcachefs                             \
@@ -16,12 +15,23 @@ CFLAGS+=-std=gnu99 -O2 -g -MMD -Wall                                \
        $(EXTRA_CFLAGS)
 LDFLAGS+=-O2 -g
 
-ifdef D
-       CFLAGS+=-Werror
-else
+CC_VERSION=$(shell $(CC) -v 2>&1|grep -E '(gcc|clang) version')
+
+ifneq (,$(findstring gcc,$(CC_VERSION)))
+       CFLAGS+=-Wno-unused-but-set-variable
+ifndef D
        CFLAGS+=-flto
        LDFLAGS+=-flto
 endif
+endif
+
+ifneq (,$(findstring clang,$(CC_VERSION)))
+       CFLAGS+=-Wno-missing-braces
+endif
+
+ifdef D
+       CFLAGS+=-Werror
+endif
 
 PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib"
 CFLAGS+=`pkg-config --cflags   ${PKGCONFIG_LIBS}`
index 64f7f3796c370a66038f571984da94f0f866d219..cfd6e59cadd570b979fbbc13aabc4e033fe87be0 100644 (file)
@@ -192,14 +192,14 @@ static struct bpos parse_pos(char *buf)
        char *s = buf;
        char *inode     = strsep(&s, ":");
        char *offset    = strsep(&s, ":");
-       struct bpos ret = { 0 };
+       u64 inode_v, offset_v;
 
        if (!inode || !offset || s ||
-           kstrtoull(inode, 10, &ret.inode) ||
-           kstrtoull(offset, 10, &ret.offset))
+           kstrtoull(inode, 10, &inode_v) ||
+           kstrtoull(offset, 10, &offset_v))
                die("invalid bpos %s", buf);
 
-       return ret;
+       return (struct bpos) { .inode = inode_v, .offset = offset_v };
 }
 
 static void list_keys_usage(void)
index 382d31a03047697cc187f686d2e1db8bb7bbc5e9..a332db3de1ad520f8070b2e51caa7aa3d785f3a0 100644 (file)
--- a/cmd_fs.c
+++ b/cmd_fs.c
@@ -23,9 +23,10 @@ int cmd_fs_show(int argc, char *argv[])
        if (argc != 2)
                die("Please supply a filesystem");
 
+#if 0
        struct bcache_handle fs = bcache_fs_open(argv[1]);
+#endif
 
-       fs = fs;
        return 0;
 }
 
@@ -34,8 +35,9 @@ int cmd_fs_set(int argc, char *argv[])
        if (argc != 2)
                die("Please supply a filesystem");
 
+#if 0
        struct bcache_handle fs = bcache_fs_open(argv[1]);
+#endif
 
-       fs = fs;
        return 0;
 }
index 1c793b5151febaf5cb00def2e94e517175a0adcf..eb15726991c2d6fd3b708d17800f1af595f75a5e 100644 (file)
@@ -4,8 +4,8 @@
 #include <linux/backing-dev.h>
 #include <linux/blk_types.h>
 #include <linux/kobject.h>
+#include <linux/types.h>
 
-typedef u64 sector_t;
 typedef unsigned fmode_t;
 
 struct bio;
index f01e5f7cfe4778f1405bd118b7cbfdf3f02e62be..aa5776c72eee22f7d057f70f6acb13b96f76928a 100644 (file)
 #define WARN(cond, ...)                assert(!(cond))
 
 #define WARN_ON(condition) ({                                          \
-       int __ret_warn_on = !!(condition);                              \
-       if (unlikely(__ret_warn_on))                                    \
+       int __ret_warn_on = unlikely(!!(condition));                    \
+       if (__ret_warn_on)                                              \
                __WARN();                                               \
-       unlikely(__ret_warn_on);                                        \
+       __ret_warn_on;                                                  \
 })
 
 #endif /* __TOOLS_LINUX_BUG_H */
index 0fa79a375c2b7096159158f6eeeec57494c83b43..c9be6b61028a7d6a915dfa6a8639e6146273fcee 100644 (file)
@@ -30,7 +30,7 @@ static inline void raw_spin_unlock(raw_spinlock_t *lock)
 
 #define raw_spin_lock_irqsave(lock, flags)             \
 do {                                                   \
-       (void) flags;                                   \
+       flags = 0;                                      \
        raw_spin_lock(lock);                            \
 } while (0)