diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2018-03-06 23:52:08 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2018-03-06 23:52:08 +0000 |
commit | 0b03de74bc5b19692e4b77df64882c6602f41161 (patch) | |
tree | 7a665402407ba5399434df2c76d15bc289cf0d37 | |
parent | 2f0842fe61f01f300aeee539cc83164b0dfd25d5 (diff) | |
download | strace-0b03de74bc5b19692e4b77df64882c6602f41161.tar.gz |
build: prepare for -Wimplicit-fallthrough=5
* 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.
-rw-r--r-- | block.c | 2 | ||||
-rw-r--r-- | btrfs.c | 4 | ||||
-rw-r--r-- | dm.c | 2 | ||||
-rw-r--r-- | gcc_compat.h | 6 | ||||
-rw-r--r-- | ioctl.c | 1 | ||||
-rw-r--r-- | loop.c | 4 | ||||
-rw-r--r-- | m4/st_warn_cflags.m4 | 1 | ||||
-rw-r--r-- | mtd.c | 2 | ||||
-rw-r--r-- | process.c | 2 | ||||
-rw-r--r-- | quota.c | 6 | ||||
-rw-r--r-- | rtc.c | 6 | ||||
-rw-r--r-- | term.c | 6 | ||||
-rw-r--r-- | tests/ioctl_v4l2.c | 11 | ||||
-rw-r--r-- | ucopy.c | 2 | ||||
-rw-r--r-- | unwind.c | 4 | ||||
-rw-r--r-- | v4l2.c | 6 |
16 files changed, 41 insertions, 24 deletions
@@ -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: @@ -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]; @@ -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: diff --git a/gcc_compat.h b/gcc_compat.h index 956aff176..b55092fd9 100644 --- a/gcc_compat.h +++ b/gcc_compat.h @@ -93,4 +93,10 @@ # 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 */ @@ -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': @@ -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; diff --git a/m4/st_warn_cflags.m4 b/m4/st_warn_cflags.m4 index 04d45442d..35f40b589 100644 --- a/m4/st_warn_cflags.m4 +++ b/m4/st_warn_cflags.m4 @@ -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]) @@ -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; @@ -219,7 +219,7 @@ SYS_FUNC(ptrace) /* print data on exiting syscall */ return 0; } - /* fall through */ + ATTRIBUTE_FALLTHROUGH; default: printaddr(data); break; @@ -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; @@ -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); @@ -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: diff --git a/tests/ioctl_v4l2.c b/tests/ioctl_v4l2.c index 8cf22777c..4b7a1262a 100644 --- a/tests/ioctl_v4l2.c +++ b/tests/ioctl_v4l2.c @@ -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 } @@ -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) @@ -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); @@ -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"); |