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.
This commit is contained in:
Дмитрий Левин 2018-03-06 23:52:08 +00:00
parent 2f0842fe61
commit 0b03de74bc
16 changed files with 41 additions and 24 deletions

View File

@ -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:

View File

@ -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];

2
dm.c
View File

@ -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:

View File

@ -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 */

View File

@ -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':

4
loop.c
View File

@ -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;

View 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])

2
mtd.c
View File

@ -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;

View File

@ -219,7 +219,7 @@ SYS_FUNC(ptrace)
/* print data on exiting syscall */
return 0;
}
/* fall through */
ATTRIBUTE_FALLTHROUGH;
default:
printaddr(data);
break;

View File

@ -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;

6
rtc.c
View File

@ -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);

6
term.c
View File

@ -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:

View 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
}

View File

@ -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)

View File

@ -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);

6
v4l2.c
View File

@ -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");