linux/drivers/usb
Kees Cook c06a1c378a usb: gadget: net2280: Distribute switch variables for initialization
Variables declared in a switch statement before any case statements
cannot be automatically initialized with compiler instrumentation (as
they are not part of any execution flow). With GCC's proposed automatic
stack variable initialization feature, this triggers a warning (and they
don't get initialized). Clang's automatic stack variable initialization
(via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also
doesn't initialize such variables[1]. Note that these warnings (or silent
skipping) happen before the dead-store elimination optimization phase,
so even when the automatic initializations are later elided in favor of
direct initializations, the warnings remain.

To avoid these problems, move such variables into the "case" where
they're used or lift them up into the main function body.

drivers/usb/gadget/udc/net2280.c: In function ‘handle_stat0_irqs_superspeed’:
drivers/usb/gadget/udc/net2280.c:2871:22: warning: statement will never be executed [-Wswitch-unreachable]
 2871 |   struct net2280_ep *e;
      |                      ^

[1] https://bugs.llvm.org/show_bug.cgi?id=44916

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/202002201515.DFC51CF@keescook
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-04 10:51:21 +01:00
..
atm USB: Replace zero-length array with flexible-array member 2020-02-23 19:24:51 +01:00
c67x00
cdns3 usb: cdns3: remove redundant assignment to pointer trb 2020-02-10 11:15:27 -08:00
chipidea usb: chipidea: add inline for ci_hdrc_host_driver_init if host is not defined 2020-01-22 07:54:27 +01:00
class compat_ioctl: remove most of fs/compat_ioctl.c 2019-12-01 13:46:15 -08:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-10 11:41:20 +01:00
core Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
dwc2 Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
dwc3 Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
early remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
gadget usb: gadget: net2280: Distribute switch variables for initialization 2020-03-04 10:51:21 +01:00
host Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
image Merge 5.4-rc3 into usb-next 2019-10-14 07:09:59 +02:00
isp1760 remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
misc Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-10 11:41:20 +01:00
mtu3 Merge 5.4-rc6 into usb-next 2019-11-04 06:41:09 +01:00
musb usb: musb: core: remove useless cast for driver.name 2020-02-19 11:10:27 +01:00
phy usb: phy: tegra: Add clarifying comments about the shared registers 2020-02-10 11:12:15 -08:00
renesas_usbhs phy: for 5.6 2020-01-17 07:52:26 +01:00
roles usb: use kobj_to_dev() API 2020-02-14 08:38:15 -08:00
serial Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
storage Merge 5.6-rc3 into usb-next 2020-02-24 08:48:49 +01:00
typec usb: typec: Add sysfs node to show cc orientation 2020-03-04 10:51:21 +01:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2019-12-17 16:36:33 +01:00
Kconfig usb: common: create Kconfig file 2019-09-03 19:00:39 +02:00
Makefile USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00