summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-04-04 00:28:13 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2017-04-04 06:43:08 -0800
commit978c16040525ffe1199bed6afd799eaa64d0f01c (patch)
tree789f68229be0af9579238a6d1e86af576ab33b3d
parent64c325ef483c863c720a7f53c6b3126e583e05a0 (diff)
Fix some clang warnings
the issue in cmd_debug - passing members of struct bpos to kstrtoull, which aren't aligned - was a legit bug
-rw-r--r--Makefile18
-rw-r--r--cmd_debug.c8
-rw-r--r--cmd_fs.c6
-rw-r--r--include/linux/blkdev.h2
-rw-r--r--include/linux/bug.h6
-rw-r--r--include/linux/spinlock.h2
6 files changed, 27 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 0822433c..e8a80c7c 100644
--- 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}`
diff --git a/cmd_debug.c b/cmd_debug.c
index 64f7f379..cfd6e59c 100644
--- a/cmd_debug.c
+++ b/cmd_debug.c
@@ -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)
diff --git a/cmd_fs.c b/cmd_fs.c
index 382d31a0..a332db3d 100644
--- 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;
}
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1c793b51..eb157269 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -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;
diff --git a/include/linux/bug.h b/include/linux/bug.h
index f01e5f7c..aa5776c7 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -22,10 +22,10 @@
#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 */
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 0fa79a37..c9be6b61 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -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)