Whamcloud - gitweb
libcom_err: deal with the fact that the Hurd error messages are not zero-based
[tools/e2fsprogs.git] / misc / filefrag.c
index c8444d7..1eec146 100644 (file)
@@ -45,7 +45,9 @@ extern int optind;
 #include <sys/stat.h>
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
+#ifdef HAVE_LINUX_FD_H
 #include <linux/fd.h>
+#endif
 #include <ext2fs/ext2fs.h>
 #include <ext2fs/ext2_types.h>
 #include <ext2fs/fiemap.h>
@@ -208,7 +210,7 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
        __u64 buf[2048];        /* __u64 for proper field alignment */
        struct fiemap *fiemap = (struct fiemap *)buf;
        struct fiemap_extent *fm_ext = &fiemap->fm_extents[0];
-       struct fiemap_extent fm_last = {0};
+       struct fiemap_extent fm_last;
        int count = (sizeof(buf) - sizeof(*fiemap)) /
                        sizeof(struct fiemap_extent);
        unsigned long long expected = 0;
@@ -221,6 +223,7 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
        int rc;
 
        memset(fiemap, 0, sizeof(struct fiemap));
+       memset(&fm_last, 0, sizeof(fm_last));
 
        if (sync_file)
                flags |= FIEMAP_FLAG_SYNC;
@@ -534,15 +537,19 @@ 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':
                                                blocksize *= 1024;
-                                               /* no break */
+                                               /* fall through */
                                        case 'm':
                                        case 'M':
                                                blocksize *= 1024;
-                                               /* no break */
+                                               /* fall through */
                                        case 'k':
                                        case 'K':
                                                blocksize *= 1024;
@@ -550,6 +557,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 */