OSDN Git Service

octeontx2: fix -Wnonnull warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 23 Mar 2021 12:53:29 +0000 (13:53 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Mar 2021 22:14:15 +0000 (15:14 -0700)
commitb7fbc88692e60a4955ac54af0bcf7f2162761339
tree0f501bfdb670ef5a8db212748476a8b385922ffb
parent341f67e424e572bfc034daa534c6fa667533e6a4
octeontx2: fix -Wnonnull warning

When compile testing this driver on a platform on which probe() is
known to fail at compile time, gcc warns about the cgx_lmactype_string[]
array being uninitialized:

In function 'strncpy',
    inlined from 'link_status_user_format' at /git/arm-soc/drivers/net/ethernet/marvell/octeontx2/af/cgx.c:838:2,
    inlined from 'cgx_link_change_handler' at /git/arm-soc/drivers/net/ethernet/marvell/octeontx2/af/cgx.c:853:2:
include/linux/fortify-string.h:27:30: error: argument 2 null where non-null expected [-Werror=nonnull]
   27 | #define __underlying_strncpy __builtin_strncpy

Address this by turning the runtime initialization into a fixed array,
which should also produce better code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/octeontx2/af/cgx.c