]> granicus.if.org Git - strace/commitdiff
build: prepare for -Wimplicit-fallthrough=5
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 6 Mar 2018 23:52:08 +0000 (23:52 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 6 Mar 2018 23:52:08 +0000 (23:52 +0000)
* gcc_compat.h (ATTRIBUTE_FALLTHROUGH): New macro.
* block.c (block_ioctl): Use it instead of "fall through" comment.
* btrfs.c (btrfs_ioctl): Likewise.
* loop.c (loop_ioctl): Likewise.
* mtd.c (mtd_ioctl): Likewise.
* rtc.c (rtc_ioctl): Likewise.
* v4l2.c (v4l2_ioctl): Likewise.
* dm.c (dm_decode_values): Likewise.
* process.c (SYS_FUNC(ptrace)): Likewise.
* quota.c (decode_cmd_data): Likewise.
* ucopy.c (umovestr): Likewise.
* unwind.c (unwind_print_stacktrace, unwind_capture_stacktrace)):
Likewise.
* term.c (term_ioctl): Add ATTRIBUTE_FALLTHROUGH.
* ioctl.c (ioctl_decode) [ALPHA || POWERPC]: Likewise.
* m4/st_warn_cflags.m4 (gl_WARN_ADD): Add -Wimplicit-fallthrough=5.
* tests/ioctl_v4l2.c (init_v4l2_format): Reorganize the switch statement
without implicit fallthrough.

16 files changed:
block.c
btrfs.c
dm.c
gcc_compat.h
ioctl.c
loop.c
m4/st_warn_cflags.m4
mtd.c
process.c
quota.c
rtc.c
term.c
tests/ioctl_v4l2.c
ucopy.c
unwind.c
v4l2.c

diff --git a/block.c b/block.c
index b402f6835f04cbb2d1aa05ec88c3ffc81e3c7d94..f31ef1428fd8d19ca031a00299d7d33c6d1778bc 100644 (file)
--- a/block.c
+++ b/block.c
@@ -168,7 +168,7 @@ MPERS_PRINTER_DECL(int, block_ioctl, struct tcb *const tcp,
        case BLKALIGNOFF:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        /* take a signed int */
        case BLKROSET:
        case BLKBSZSET:
diff --git a/btrfs.c b/btrfs.c
index ed3120ae3665488ef2dc2f4e6aec2f5238a1c53a..3016ec843c67646859122690f33b72dd03d55ba5 100644 (file)
--- a/btrfs.c
+++ b/btrfs.c
@@ -538,7 +538,7 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
        case BTRFS_IOC_START_SYNC: /* R */
                if (entering(tcp))
                        return 0;
-       /* fall through */
+       ATTRIBUTE_FALLTHROUGH;
        /* takes a u64 */
        case BTRFS_IOC_DEFAULT_SUBVOL: /* W */
        case BTRFS_IOC_WAIT_SYNC: /* W */
@@ -1318,7 +1318,7 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
        case BTRFS_IOC_GET_FSLABEL: /* R */
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case BTRFS_IOC_SET_FSLABEL: { /* W */
                char label[BTRFS_LABEL_SIZE];
 
diff --git a/dm.c b/dm.c
index 32b331011651b2e7e7bfedc642516cd15b835e76..17470fa1e7f4c2966d4a88c1f06a40125c267572 100644 (file)
--- a/dm.c
+++ b/dm.c
@@ -91,7 +91,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code,
                case DM_DEV_SUSPEND:
                        if (ioc->flags & DM_SUSPEND_FLAG)
                                break;
-                       /* Fall through */
+                       ATTRIBUTE_FALLTHROUGH;
                case DM_DEV_RENAME:
                case DM_DEV_REMOVE:
                case DM_DEV_WAIT:
index 956aff1767c48cf8dc4ab42f220499bb0bed8475..b55092fd90aa67c75958027c4ee91ea6dd4b2339 100644 (file)
 # define ATTRIBUTE_ALLOC_SIZE(args)    /* empty */
 #endif
 
+#if GNUC_PREREQ(7, 0)
+# define ATTRIBUTE_FALLTHROUGH __attribute__((__fallthrough__))
+#else
+# define ATTRIBUTE_FALLTHROUGH ((void) 0)
+#endif
+
 #endif /* !STRACE_GCC_COMPAT_H */
diff --git a/ioctl.c b/ioctl.c
index 9fd74924f4f05ccbf81a94d67285ef3914b04af4..5a59f379ef9c22079c92c5537d2425ccbd719777 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -263,6 +263,7 @@ ioctl_decode(struct tcb *tcp)
                int ret = file_ioctl(tcp, code, arg);
                if (ret != RVAL_DECODED)
                        return ret;
+               ATTRIBUTE_FALLTHROUGH;
        }
        case 't':
        case 'T':
diff --git a/loop.c b/loop.c
index 33bd038576505a4249181824e95c49bfd6b70f00..291f5646c1f0b1d06e2570c1f58e52d46d9ea57b 100644 (file)
--- a/loop.c
+++ b/loop.c
@@ -156,7 +156,7 @@ MPERS_PRINTER_DECL(int, loop_ioctl,
        case LOOP_GET_STATUS:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case LOOP_SET_STATUS:
                decode_loop_info(tcp, arg);
                break;
@@ -164,7 +164,7 @@ MPERS_PRINTER_DECL(int, loop_ioctl,
        case LOOP_GET_STATUS64:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case LOOP_SET_STATUS64:
                decode_loop_info64(tcp, arg);
                break;
index 04d45442da2c0be7a953a9c549c929dab7e92347..35f40b589822cd5328dc4e750c17b7fb210eb4ca 100644 (file)
@@ -3,6 +3,7 @@ gl_WARN_ADD([-Wall])
 gl_WARN_ADD([-Wempty-body])
 gl_WARN_ADD([-Wformat-security])
 gl_WARN_ADD([-Wignored-qualifiers])
+gl_WARN_ADD([-Wimplicit-fallthrough=5])
 gl_WARN_ADD([-Winit-self])
 gl_WARN_ADD([-Wlogical-op])
 gl_WARN_ADD([-Wmissing-parameter-type])
diff --git a/mtd.c b/mtd.c
index 52957f9d36746046efe74625147d8190e52d6276..cf4e30c3de7f7b615daed1d728a78bbfa56e5175 100644 (file)
--- a/mtd.c
+++ b/mtd.c
@@ -274,7 +274,7 @@ MPERS_PRINTER_DECL(int, mtd_ioctl, struct tcb *const tcp,
        case OTPGETREGIONINFO:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case OTPLOCK:
                decode_otp_info(tcp, arg);
                break;
index 895fc4b8fc53e05d015571a1b13029376029ac0d..f5733417c66afea1a3f515d69ac745d1bf7dcabe 100644 (file)
--- a/process.c
+++ b/process.c
@@ -219,7 +219,7 @@ SYS_FUNC(ptrace)
                                /* print data on exiting syscall */
                                return 0;
                        }
-                       /* fall through */
+                       ATTRIBUTE_FALLTHROUGH;
                default:
                        printaddr(data);
                        break;
diff --git a/quota.c b/quota.c
index ba1d7612ab160cfef60ee085a2a851bcba4f9ede..a051bd8834e91d21bea9413103841f45fd487c50 100644 (file)
--- a/quota.c
+++ b/quota.c
@@ -177,7 +177,7 @@ decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, kernel_ulong_t data)
                        return 0;
                }
 
-               /* Fall-through */
+               ATTRIBUTE_FALLTHROUGH;
        case Q_SETQUOTA:
        {
                struct if_dqblk dq;
@@ -247,7 +247,7 @@ decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, kernel_ulong_t data)
                        return 0;
                }
 
-               /* Fall-through */
+               ATTRIBUTE_FALLTHROUGH;
        case Q_XSETQLIM:
        {
                struct xfs_dqblk dq;
@@ -310,7 +310,7 @@ decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, kernel_ulong_t data)
                        return 0;
                }
 
-               /* Fall-through */
+               ATTRIBUTE_FALLTHROUGH;
        case Q_SETINFO:
        {
                struct if_dqinfo dq;
diff --git a/rtc.c b/rtc.c
index 9c02cbd50812178b9fc47d5cf06504bd9f7b04b0..b5c65da9f0663c95ab64ca1868a89ff75fa886d2 100644 (file)
--- a/rtc.c
+++ b/rtc.c
@@ -93,7 +93,7 @@ MPERS_PRINTER_DECL(int, rtc_ioctl, struct tcb *const tcp,
        case RTC_RD_TIME:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case RTC_ALM_SET:
        case RTC_SET_TIME:
                tprints(", ");
@@ -113,7 +113,7 @@ MPERS_PRINTER_DECL(int, rtc_ioctl, struct tcb *const tcp,
        case RTC_WKALM_RD:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case RTC_WKALM_SET:
                tprints(", ");
                decode_rtc_wkalrm(tcp, arg);
@@ -121,7 +121,7 @@ MPERS_PRINTER_DECL(int, rtc_ioctl, struct tcb *const tcp,
        case RTC_PLL_GET:
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case RTC_PLL_SET:
                tprints(", ");
                decode_rtc_pll_info(tcp, arg);
diff --git a/term.c b/term.c
index 9368e5fd58ee3b209cb19b136b1c0ce257b27194..0f13f5f11cba73a6837e87ec5b4c7db1bed8a46b 100644 (file)
--- a/term.c
+++ b/term.c
@@ -160,6 +160,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCGLCKTRMIOS:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TCSETS:
 #ifdef TCSETS2
        case TCSETS2:
@@ -180,6 +181,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TCGETA:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TCSETA:
        case TCSETAW:
        case TCSETAF:
@@ -190,6 +192,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCGWINSZ:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSWINSZ:
                decode_winsize(tcp, arg);
                break;
@@ -199,6 +202,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCGSIZE:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSSIZE:
                decode_ttysize(tcp, arg);
                break;
@@ -223,6 +227,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCMGET:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
@@ -245,6 +250,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
 #endif
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSPGRP:
        case TIOCSETD:
        case FIONBIO:
index 8cf22777cb8139a485b37f32931dc62afa141789..4b7a1262a957f5bd108cb5a8f90632c94b4580cb 100644 (file)
@@ -157,14 +157,17 @@ init_v4l2_format(struct v4l2_format *const f,
 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT
        case V4L2_BUF_TYPE_SDR_OUTPUT:
                f->fmt.sdr.pixelformat = sf_magic;
+# ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
+               f->fmt.sdr.buffersize = 0x25afabfb;
+# endif
+               break;
 #endif
 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE
        case V4L2_BUF_TYPE_SDR_CAPTURE:
-               if (buf_type == V4L2_BUF_TYPE_SDR_CAPTURE)
-                       f->fmt.sdr.pixelformat = magic;
-#ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
+               f->fmt.sdr.pixelformat = magic;
+# ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
                f->fmt.sdr.buffersize = 0x25afabfb;
-#endif
+# endif
                break;
 #endif
        }
diff --git a/ucopy.c b/ucopy.c
index 2d9ffb38cc14abe3a2d3bf8bfcfc58528e1c0c9f..a31f5243c137f050d8f6f1f301646abcd3c0b84c 100644 (file)
--- a/ucopy.c
+++ b/ucopy.c
@@ -306,7 +306,7 @@ umovestr(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len,
                                if (!nread)
                                        return umovestr_peekdata(pid, addr,
                                                                 len, laddr);
-                               /* fall through */
+                               ATTRIBUTE_FALLTHROUGH;
                        case EFAULT: case EIO:
                                /* address space is inaccessible */
                                if (nread)
index cbb5206bc37d3ba6e368cf815f38778c6bbfb376..a272fba8fd6158e629622a30814f372c0bd99242 100644 (file)
--- a/unwind.c
+++ b/unwind.c
@@ -398,7 +398,7 @@ unwind_print_stacktrace(struct tcb *tcp)
        } else switch (mmap_cache_rebuild_if_invalid(tcp, __func__)) {
                case MMAP_CACHE_REBUILD_RENEWED:
                        unw_flush_cache(libunwind_as, 0, 0);
-                       /* Fall through */
+                       ATTRIBUTE_FALLTHROUGH;
                case MMAP_CACHE_REBUILD_READY:
                        debug_func_msg("walk: tcp=%p, queue=%p", tcp, tcp->queue->head);
                        stacktrace_walk(tcp, print_call_cb, print_error_cb, NULL);
@@ -427,7 +427,7 @@ unwind_capture_stacktrace(struct tcb *tcp)
        switch (mmap_cache_rebuild_if_invalid(tcp, __func__)) {
        case MMAP_CACHE_REBUILD_RENEWED:
                unw_flush_cache(libunwind_as, 0, 0);
-               /* Fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case MMAP_CACHE_REBUILD_READY:
                stacktrace_walk(tcp, queue_put_call, queue_put_error,
                                tcp->queue);
diff --git a/v4l2.c b/v4l2.c
index 41f62c7f80affb3b5402e07810b963e5000accff..7081c81cc7fb9ecfd2c220f50f6f652b61bc1356 100644 (file)
--- a/v4l2.c
+++ b/v4l2.c
@@ -1022,7 +1022,7 @@ MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
        case VIDIOC_G_FBUF: /* R */
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case VIDIOC_S_FBUF: /* W */
                return print_v4l2_framebuffer(tcp, arg);
 
@@ -1037,7 +1037,7 @@ MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
        case VIDIOC_G_STD: /* R */
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case VIDIOC_S_STD: /* W */
                tprints(", ");
                printnum_int64(tcp, arg, "%#" PRIx64);
@@ -1063,7 +1063,7 @@ MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
        case VIDIOC_G_INPUT: /* R */
                if (entering(tcp))
                        return 0;
-               /* fall through */
+               ATTRIBUTE_FALLTHROUGH;
        case VIDIOC_S_INPUT: /* RW */
                tprints(", ");
                printnum_int(tcp, arg, "%u");