Thread (65 messages) 65 messages, 19 authors, 2020-12-08

Re: [PATCH 000/141] Fix fall-through warnings for Clang

From: Dan Carpenter <hidden>
Date: 2020-12-01 14:13:29
Also in: alsa-devel, amd-gfx, bridge, ceph-devel, dm-devel, dri-devel, intel-gfx, intel-wired-lan, keyrings, linux-acpi, linux-arm-msm, linux-block, linux-can, linux-cifs, linux-crypto, linux-ext4, linux-gpio, linux-hardening, linux-hwmon, linux-i3c, linux-ide, linux-iio, linux-input, linux-integrity, linux-media, linux-mediatek, linux-mm, linux-mmc, linux-nfs, linux-rdma, linux-renesas-soc, linux-scsi, linux-sctp, linux-security-module, linux-usb, linux-watchdog, linux-wireless, lkml, netdev, netfilter-devel, op-tee, selinux, target-devel, virtualization, xen-devel

On Mon, Nov 23, 2020 at 05:32:51PM -0800, Nick Desaulniers wrote:
On Sun, Nov 22, 2020 at 8:17 AM Kees Cook [off-list ref] wrote:
quoted
On Fri, Nov 20, 2020 at 11:51:42AM -0800, Jakub Kicinski wrote:
quoted
If none of the 140 patches here fix a real bug, and there is no change
to machine code then it sounds to me like a W=2 kind of a warning.
FWIW, this series has found at least one bug so far:
https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=Kr_CQ@mail.gmail.com/ (local)
So looks like the bulk of these are:
switch (x) {
  case 0:
    ++x;
  default:
    break;
}
This should not generate a warning.
I have a patch that fixes those up for clang:
https://reviews.llvm.org/D91895

There's 3 other cases that don't quite match between GCC and Clang I
observe in the kernel:
switch (x) {
  case 0:
    ++x;
  default:
    goto y;
}
y:;
This should generate a warning.
switch (x) {
  case 0:
    ++x;
  default:
    return;
}
Warn for this.

switch (x) {
  case 0:
    ++x;
  default:
    ;
}
Don't warn for this.

If adding a break statement changes the flow of the code then warn about
potentially missing break statements, but if it doesn't change anything
then don't warn about it.

regards,
dan carpenter
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help