Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC, sb_edac: Simplify switch statement

clang static analyzer reports this problem

sb_edac.c:959:2: warning: Undefined or garbage value
returned to caller
return type;
^~~~~~~~~~~

This is a false positive.

However by initializing the type to DEV_UNKNOWN the 3 case can be
removed from the switch, saving a comparison and jump.

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20200907153225.7294-1-trix@redhat.com

authored by

Tom Rix and committed by
Tony Luck
fbd4ab78 66077adb

+1 -4
+1 -4
drivers/edac/sb_edac.c
··· 939 939 940 940 static enum dev_type __ibridge_get_width(u32 mtr) 941 941 { 942 - enum dev_type type; 942 + enum dev_type type = DEV_UNKNOWN; 943 943 944 944 switch (mtr) { 945 - case 3: 946 - type = DEV_UNKNOWN; 947 - break; 948 945 case 2: 949 946 type = DEV_X16; 950 947 break;