mirror_ubuntu-kernels/drivers/net/ethernet/intel
Kees Cook a34c7f5156 e1000: 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/net/ethernet/intel/e1000/e1000_main.c: In function ‘e1000_xmit_frame’:
drivers/net/ethernet/intel/e1000/e1000_main.c:3143:18: warning: statement will never be executed [-Wswitch-unreachable]
 3143 |     unsigned int pull_size;
      |                  ^~~~~~~~~

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

Signed-off-by: Kees Cook <keescook@chromium.org>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2020-04-17 10:19:24 -07:00
..
e1000 e1000: Distribute switch variables for initialization 2020-04-17 10:19:24 -07:00
e1000e Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-03-31 17:29:33 -07:00
fm10k net: fm10k: reject unsupported coalescing params 2020-03-12 11:32:36 -07:00
i40e net: i40e: reject unsupported coalescing params 2020-03-12 11:32:36 -07:00
iavf net: iavf: reject unsupported coalescing params 2020-03-12 11:32:36 -07:00
ice pci-v5.7-changes 2020-04-03 14:25:02 -07:00
igb igb: convert to use i2c_new_client_device() 2020-03-26 19:31:21 -07:00
igbvf net: igbvf: reject unsupported coalescing params 2020-03-12 11:32:36 -07:00
igc igc: Add support for ETF offloading 2020-04-17 10:19:24 -07:00
ixgb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2019-12-22 15:15:05 -08:00
ixgbe net: ixgbe: reject unsupported coalescing params 2020-03-12 11:32:36 -07:00
ixgbevf net: ixgbevf: reject unsupported coalescing params 2020-03-12 11:32:36 -07:00
e100.c netdev: pass the stuck queue to the timeout handler 2019-12-12 21:38:57 -08:00
Kconfig ice: enable initial devlink support 2020-03-21 00:55:42 -07:00
Makefile igc: Add skeletal frame for Intel(R) 2.5G Ethernet Controller support 2018-10-17 12:14:54 -07:00