net: ethernet: sun: Zero initialize class in default case in niu_add_ethtool_tcam_entry
authorNathan Chancellor <natechancellor@gmail.com>
Thu, 7 Mar 2019 23:29:33 +0000 (16:29 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Mar 2019 23:26:21 +0000 (15:26 -0800)
When building with -Wsometimes-uninitialized, Clang warns:

drivers/net/ethernet/sun/niu.c:7466:5: warning: variable 'class' is used
uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]

The default case can never happen because i can only be 0 to 3
(NIU_L3_PROG_CLS is defined as 4). To make this clear to Clang,
just zero initialize class in the default case (use the macro
CLASS_CODE_UNRECOG to make it clear this shouldn't happen).

Link: https://github.com/ClangBuiltLinux/linux/issues/403
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sun/niu.c

index d84501441eddeb812156ae206e92c869aa41f426..6f99437a696203849344de81e381c7839ca4c0ee 100644 (file)
@@ -7464,6 +7464,7 @@ static int niu_add_ethtool_tcam_entry(struct niu *np,
                                        class = CLASS_CODE_USER_PROG4;
                                        break;
                                default:
+                                       class = CLASS_CODE_UNRECOG;
                                        break;
                                }
                                ret = tcam_user_ip_class_set(np, class, 0,