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 #include #include +#include -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)