From e0c54d52f534888d526d6fd3e23b8a706ccc1198 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 17 Aug 2017 15:11:06 -0600 Subject: [PATCH] Workarounds for building with gcc 4 --- Makefile | 3 ++- cmd_assemble.c | 3 ++- cmd_migrate.c | 6 ++++-- include/uapi/linux/xattr.h | 4 ---- libbcachefs.c | 3 ++- tools-util.h | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 227ce200..cd338fa0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PREFIX=/usr INSTALL=install -CFLAGS+=-std=gnu99 -O2 -g -MMD -Wall \ +CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall \ -Wno-pointer-sign \ -fno-strict-aliasing \ -I. -Iinclude -Ilibbcachefs \ @@ -31,6 +31,7 @@ endif ifdef D CFLAGS+=-Werror + CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y endif PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib" diff --git a/cmd_assemble.c b/cmd_assemble.c index 735b368a..051c32f8 100644 --- a/cmd_assemble.c +++ b/cmd_assemble.c @@ -23,7 +23,8 @@ int cmd_assemble(int argc, char *argv[]) memset(assemble, 0, sizeof(*assemble)); assemble->nr_devs = nr_devs; - for (unsigned i = 1; i < argc; i++) + unsigned i; + for (i = 1; i < argc; i++) assemble->devs[i] = (__u64) argv[i]; xioctl(bcachectl_open(), BCH_IOCTL_ASSEMBLE, assemble); diff --git a/cmd_migrate.c b/cmd_migrate.c index 2e31b9e2..b291cb51 100644 --- a/cmd_migrate.c +++ b/cmd_migrate.c @@ -225,7 +225,8 @@ static void copy_xattrs(struct bch_fs *c, struct bch_inode_unpacked *dst, if (attrs_size < 0) die("listxattr error: %m"); - for (const char *next, *attr = attrs; + const char *next, *attr; + for (attr = attrs; attr < attrs + attrs_size; attr = next) { next = attr + strlen(attr) + 1; @@ -827,7 +828,8 @@ int cmd_migrate_superblock(int argc, char *argv[]) if (sb->layout.nr_superblocks >= ARRAY_SIZE(sb->layout.sb_offset)) die("Can't add superblock: no space left in superblock layout"); - for (unsigned i = 0; i < sb->layout.nr_superblocks; i++) + unsigned i; + for (i = 0; i < sb->layout.nr_superblocks; i++) if (le64_to_cpu(sb->layout.sb_offset[i]) == BCH_SB_SECTOR) die("Superblock layout already has default superblock"); diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h index 1590c49c..c95882b3 100644 --- a/include/uapi/linux/xattr.h +++ b/include/uapi/linux/xattr.h @@ -13,12 +13,8 @@ #ifndef _UAPI_LINUX_XATTR_H #define _UAPI_LINUX_XATTR_H -#if __UAPI_DEF_XATTR -#define __USE_KERNEL_XATTR_DEFS - #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ -#endif /* Namespaces */ #define XATTR_OS2_PREFIX "os2." diff --git a/libbcachefs.c b/libbcachefs.c index f68a45f2..9a07bbcd 100644 --- a/libbcachefs.c +++ b/libbcachefs.c @@ -247,7 +247,8 @@ void bch2_super_write(int fd, struct bch_sb *sb) { struct nonce nonce = { 0 }; - for (unsigned i = 0; i < sb->layout.nr_superblocks; i++) { + unsigned i; + for (i = 0; i < sb->layout.nr_superblocks; i++) { sb->offset = sb->layout.sb_offset[i]; if (sb->offset == BCH_SB_SECTOR) { diff --git a/tools-util.h b/tools-util.h index 0b73b283..14ced032 100644 --- a/tools-util.h +++ b/tools-util.h @@ -54,7 +54,7 @@ struct units_buf { char b[20]; }; -#define pr_units(_v, _u) __pr_units(_v, _u).b +#define pr_units(_v, _u) &(__pr_units(_v, _u).b[0]) char *read_file_str(int, const char *); u64 read_file_u64(int, const char *);