aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Dongyang <dongyangli@ddn.com>2018-07-13 18:42:48 -0600
committerTheodore Ts'o <tytso@mit.edu>2018-07-14 20:46:30 -0400
commitfddc423dc6353552772969d70cec08e8378d8e57 (patch)
tree8086b02c564916b3c7c6174d093284d4bbbd9ef1
parente96393142ccd1da25ac1e2c9cebd7f20326f36c5 (diff)
downloade2fsprogs-fddc423dc6353552772969d70cec08e8378d8e57.tar.gz
Fix compile error and warnings for old gcc versions
-Wimplicit-fallthrough option was added in gcc7 and -Wpedantic was added in gcc4.8, while #pragma GCC diagnostic support was not available until gcc4.6 We got following warnings: ../lib/ext2fs/fiemap.h:35: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’ ../lib/ext2fs/fiemap.h:36: warning: unknown option after ‘#pragma GCC diagnostic’ kind ../lib/ext2fs/fiemap.h:38: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’ and error: filefrag.c: In function ‘main’: filefrag.c:577: error: #pragma GCC diagnostic not allowed inside functions filefrag.c:578: error: #pragma GCC diagnostic not allowed inside functions filefrag.c:595: error: #pragma GCC diagnostic not allowed inside functions when compiling latest e2fsprogs with a gcc older than 4.6 e.g. on CentOS 6.9 Signed-off-by: Li Dongyang <dongyangli@ddn.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--debugfs/set_fields.c4
-rw-r--r--e2fsck/problem.c4
-rw-r--r--lib/ext2fs/ext4_acl.h4
-rw-r--r--lib/ext2fs/fiemap.h4
-rw-r--r--lib/ext2fs/hashmap.h4
-rw-r--r--lib/ext2fs/mmp.c4
-rw-r--r--lib/ext2fs/unix_io.c4
-rw-r--r--lib/uuid/gen_uuid.c4
-rw-r--r--misc/e2undo.c4
-rw-r--r--misc/filefrag.c4
-rw-r--r--misc/fuse2fs.c4
11 files changed, 44 insertions, 0 deletions
diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c
index 65949060..e1e23a5d 100644
--- a/debugfs/set_fields.c
+++ b/debugfs/set_fields.c
@@ -75,8 +75,10 @@ static errcode_t parse_gd_csum(struct field_set_info *info, char *field, char *a
static errcode_t parse_mmp_clear(struct field_set_info *info, char *field,
char *arg);
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
static struct field_set_info super_fields[] = {
{ "inodes_count", &set_sb.s_inodes_count, NULL, 4, parse_uint },
@@ -289,7 +291,9 @@ static struct field_set_info mmp_fields[] = {
{ "checksum", &set_mmp.mmp_checksum, NULL, 4, parse_uint },
{ 0, 0, 0, 0 }
};
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
+#endif
#ifdef UNITTEST
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index a0a3cfec..47321e0a 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -99,8 +99,10 @@ static const char *preen_msg[] = {
"", /* 20 */
};
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
static struct e2fsck_problem problem_table[] = {
@@ -2086,7 +2088,9 @@ static struct latch_descr pr_latch_info[] = {
{ PR_LATCH_OPTIMIZE_EXT, PR_1E_OPTIMIZE_EXT_HEADER, PR_1E_OPTIMIZE_EXT_END },
{ -1, 0, 0 },
};
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
+#endif
static struct e2fsck_problem *find_problem(problem_t code)
{
diff --git a/lib/ext2fs/ext4_acl.h b/lib/ext2fs/ext4_acl.h
index 1f5245de..8d4d9745 100644
--- a/lib/ext2fs/ext4_acl.h
+++ b/lib/ext2fs/ext4_acl.h
@@ -50,9 +50,13 @@ typedef struct {
typedef struct {
__le32 a_version;
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
posix_acl_xattr_entry a_entries[0];
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
+#endif
} posix_acl_xattr_header;
diff --git a/lib/ext2fs/fiemap.h b/lib/ext2fs/fiemap.h
index 5c851b24..0d1072ac 100644
--- a/lib/ext2fs/fiemap.h
+++ b/lib/ext2fs/fiemap.h
@@ -31,10 +31,14 @@ struct fiemap {
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
__u32 fm_extent_count; /* size of fm_extents array (in) */
__u32 fm_reserved;
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
+#endif
};
#if defined(__linux__) && !defined(FS_IOC_FIEMAP)
diff --git a/lib/ext2fs/hashmap.h b/lib/ext2fs/hashmap.h
index be1e8a76..228f4395 100644
--- a/lib/ext2fs/hashmap.h
+++ b/lib/ext2fs/hashmap.h
@@ -17,10 +17,14 @@ struct ext2fs_hashmap {
struct ext2fs_hashmap_entry *next;
struct ext2fs_hashmap_entry *list_next;
struct ext2fs_hashmap_entry *list_prev;
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
} *entries[0];
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
+#endif
};
struct ext2fs_hashmap *ext2fs_hashmap_create(
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 0cf0d0da..2da935e0 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -34,10 +34,12 @@
#define O_DIRECT 0
#endif
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic push
#ifndef CONFIG_MMP
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
+#endif
errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
{
@@ -465,4 +467,6 @@ mmp_error:
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
+#endif
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 18a2e5f7..7a4c9bf5 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -1127,8 +1127,10 @@ unimplemented:
}
/* parameters might not be used if OS doesn't support zeroout */
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
static errcode_t unix_zeroout(io_channel channel, unsigned long long block,
unsigned long long count)
{
@@ -1195,7 +1197,9 @@ err:
unimplemented:
return EXT2_ET_UNIMPLEMENTED;
}
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
+#endif
static struct struct_io_manager struct_unix_manager = {
.magic = EXT2_ET_MAGIC_IO_MANAGER,
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c
index 43ecc8ae..01983634 100644
--- a/lib/uuid/gen_uuid.c
+++ b/lib/uuid/gen_uuid.c
@@ -484,10 +484,12 @@ static void close_all_fds(void)
}
#endif /* defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) */
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic push
#if !defined(USE_UUIDD) || !defined(HAVE_SYS_UN_H)
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
+#endif
/*
* Try using the uuidd daemon to generate the UUID
*
@@ -570,7 +572,9 @@ fail:
#endif
return -1;
}
+#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
+#endif
void uuid__generate_time(uuid_t out, int *num)
{
diff --git a/misc/e2undo.c b/misc/e2undo.c
index 05937383..71991e05 100644
--- a/misc/e2undo.c
+++ b/misc/e2undo.c
@@ -81,10 +81,14 @@ struct undo_key_block {
__le32 magic; /* KEYBLOCK_MAGIC number */
__le32 crc; /* block checksum */
__le64 reserved; /* zero */
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
struct undo_key keys[0]; /* keys, which come immediately after */
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
+#endif
};
struct undo_key_info {
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 7f1c5bfc..56f84ed8 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -535,8 +535,10 @@ int main(int argc, char**argv)
char *end;
blocksize = strtoul(optarg, &end, 0);
if (end) {
+#if __GNUC_PREREQ (7, 0)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
switch (end[0]) {
case 'g':
case 'G':
@@ -553,7 +555,9 @@ int main(int argc, char**argv)
default:
break;
}
+#if __GNUC_PREREQ (7, 0)
#pragma GCC diagnostic pop
+#endif
}
} else { /* Allow -b without argument for compat. Remove
* this eventually so "-b {blocksize}" works */
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 056d34ec..5c73895e 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -118,10 +118,14 @@ typedef struct {
typedef struct {
u_int32_t a_version;
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
acl_ea_entry a_entries[0];
+#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
+#endif
} acl_ea_header;
static inline size_t acl_ea_size(int count)