mlxsw: Various static checkers fixes
Subsystems (3)
cover mlxsw: Various static checkers fixes
From: Ido Schimmel <[email protected]>
Jakub told me he gets some warnings with W=1, so I decided to check with sparse, smatch and coccinelle as well. This patch set fixes all the issues found. None are actual bugs / regressions and therefore not targeted at net.
Patches #1-#2 add missing kernel-doc comments.
Patch #3 removes dead code.
Patch #4 reworks the ACL code to avoid defining a static variable in a header file.
Patch #5 removes unnecessary conversion to bool that coccinelle warns about.
Patch #6 avoids false-positive uninitialized symbol errors emitted by smatch.
Ido Schimmel (6):
mlxsw: i2c: Add missing field documentation
mlxsw: spectrum_router: Add proper function documentation
mlxsw: spectrum: Remove unused RIF and FID families
mlxsw: core_acl: Avoid defining static variable in header file
mlxsw: switchx2: Remove unnecessary conversion to bool
mlxsw: spectrum_router: Avoid uninitialized symbol errors
.../mellanox/mlxsw/core_acl_flex_keys.c | 50 +++++- .../mellanox/mlxsw/core_acl_flex_keys.h | 36 +--- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 1 + .../ethernet/mellanox/mlxsw/spectrum_fid.c | 152 +--------------- .../ethernet/mellanox/mlxsw/spectrum_router.c | 164 ++++++------------ .../net/ethernet/mellanox/mlxsw/switchx2.c | 2 +- 6 files changed, 109 insertions(+), 296 deletions(-)
Signature · 1 line
2.24.1
PATCH 1/6 mlxsw: i2c: Add missing field documentation
From: Ido Schimmel <[email protected]>
Suppress following warning when compiling with W=1:
drivers/net/ethernet/mellanox/mlxsw//i2c.c:78: warning: Function parameter or member 'cmd' not described in 'mlxsw_i2c'
--- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/i2c.c +1 -0
@@ -53,6 +53,7 @@/** * struct mlxsw_i2c - device private data: +* @cmd: command attributes; * @cmd.mb_size_in: input mailbox size; * @cmd.mb_off_in: input mailbox offset in register space; * @cmd.mb_size_out: output mailbox size;
Signature · 1 line
2.24.1
PATCH 2/6 mlxsw: spectrum_router: Add proper function documentation
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Suppress following warnings when compiling with W=1:
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1552: warning:
Function parameter or member 'mlxsw_sp' not described in '__mlxsw_sp_ipip_entry_update_tunnel' drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1552: warning:
Function parameter or member 'ipip_entry' not described in '__mlxsw_sp_ipip_entry_update_tunnel' drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1552: warning:
Function parameter or member 'extack' not described in '__mlxsw_sp_ipip_entry_update_tunnel'
--- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +9 -5
@@ -1535,13 +1535,17 @@ static void mlxsw_sp_nexthop_rif_update(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_rif *rif);/** -* Update the offload related to an IPIP entry. This always updates decap, and -* in addition to that it also: -* @recreate_loopback: recreates the associated loopback RIF -* @keep_encap: updates next hops that use the tunnel netdevice. This is only +* __mlxsw_sp_ipip_entry_update_tunnel - Update offload related to IPIP entry. +* @mlxsw_sp: mlxsw_sp. +* @ipip_entry: IPIP entry. +* @recreate_loopback: Recreates the associated loopback RIF. +* @keep_encap: Updates next hops that use the tunnel netdevice. This is only * relevant when recreate_loopback is true. -* @update_nexthops: updates next hops, keeping the current loopback RIF. This +* @update_nexthops: Updates next hops, keeping the current loopback RIF. This * is only relevant when recreate_loopback is false. +* @extack: extack. +* +* Return: Non-zero value on failure. */ int __mlxsw_sp_ipip_entry_update_tunnel(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_ipip_entry *ipip_entry,
Signature · 1 line
2.24.1
PATCH 3/6 mlxsw: spectrum: Remove unused RIF and FID families
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
In merge commit 50853808ff4a ("Merge branch 'mlxsw-Prepare-for-VLAN-aware-bridge-w-VxLAN'") I flipped mlxsw to use emulated 802.1Q FIDs and correspondingly emulated VLAN RIFs. This means that the non-emulated variants are no longer used. Remove them and suppress the following warnings when compiling with W=1:
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:7572:38: warning:
‘mlxsw_sp_rif_vlan_ops’ defined but not used [-Wunused-const-variable=]
drivers/net/ethernet/mellanox/mlxsw//spectrum_fid.c:584:41: warning:
‘mlxsw_sp_fid_8021q_family’ defined but not used [-Wunused-const-variable=]
--- .../ethernet/mellanox/mlxsw/spectrum_fid.c | 152 +----------------- .../ethernet/mellanox/mlxsw/spectrum_router.c | 143 +++++----------- 2 files changed, 47 insertions(+), 248 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c +8 -144
@@ -438,16 +438,6 @@ static int mlxsw_sp_fid_vni_op(struct mlxsw_sp *mlxsw_sp, u16 fid_index,return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (sfmr), sfmr_pl); } -static int mlxsw_sp_fid_vid_map (struct mlxsw_sp *mlxsw_sp,u16 fid_index, -u16 vid,bool valid) -{ -enum mlxsw_reg_svfa_mt mt =MLXSW_REG_SVFA_MT_VID_TO_FID ; -char svfa_pl[MLXSW_REG_SVFA_LEN ]; - -mlxsw_reg_svfa_pack (svfa_pl,0 , mt, valid, fid_index, vid); -return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (svfa), svfa_pl); -} -static int __mlxsw_sp_fid_port_vid_map (struct mlxsw_sp *mlxsw_sp,u16 fid_index,u8 local_port,u16 vid,bool valid) {
@@ -458,140 +448,6 @@ static int __mlxsw_sp_fid_port_vid_map(struct mlxsw_sp *mlxsw_sp, u16 fid_index,return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (svfa), svfa_pl); } -static int mlxsw_sp_fid_8021q_configure (struct mlxsw_sp_fid *fid) -{ -struct mlxsw_sp *mlxsw_sp = fid->fid_family->mlxsw_sp; -struct mlxsw_sp_fid_8021q *fid_8021q; -int err; - - err =mlxsw_sp_fid_op (mlxsw_sp, fid->fid_index, fid->fid_index, true); -if (err) -return err; - - fid_8021q =mlxsw_sp_fid_8021q_fid (fid); - err =mlxsw_sp_fid_vid_map (mlxsw_sp, fid->fid_index, fid_8021q->vid, - true); -if (err) - goto err_fid_map; - -return 0 ; - -err_fid_map: -mlxsw_sp_fid_op (mlxsw_sp, fid->fid_index,0 , false); -return err; -} - -static void mlxsw_sp_fid_8021q_deconfigure (struct mlxsw_sp_fid *fid) -{ -struct mlxsw_sp *mlxsw_sp = fid->fid_family->mlxsw_sp; -struct mlxsw_sp_fid_8021q *fid_8021q; - - fid_8021q =mlxsw_sp_fid_8021q_fid (fid); -mlxsw_sp_fid_vid_map (mlxsw_sp, fid->fid_index, fid_8021q->vid, false); -mlxsw_sp_fid_op (mlxsw_sp, fid->fid_index,0 , false); -} - -static int mlxsw_sp_fid_8021q_index_alloc (struct mlxsw_sp_fid *fid, -const void *arg,u16 *p_fid_index) -{ -struct mlxsw_sp_fid_family *fid_family = fid->fid_family; -u16 vid = *(u16 *) arg; - -/* Use 1:1 mapping for simplicity although not a must */ -if (vid < fid_family->start_index || vid > fid_family->end_index) -return -EINVAL ; - *p_fid_index = vid; - -return 0 ; -} - -static bool -mlxsw_sp_fid_8021q_compare (const struct mlxsw_sp_fid *fid,const void *arg) -{ -u16 vid = *(u16 *) arg; - -return mlxsw_sp_fid_8021q_fid (fid)->vid == vid; -} - -static u16 mlxsw_sp_fid_8021q_flood_index (const struct mlxsw_sp_fid *fid) -{ -return fid->fid_index; -} - -static int mlxsw_sp_fid_8021q_port_vid_map (struct mlxsw_sp_fid *fid, -struct mlxsw_sp_port *mlxsw_sp_port, -u16 vid) -{ -struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; -u8 local_port = mlxsw_sp_port->local_port; - -/* In case there are no {Port, VID} => FID mappings on the port, -* we can use the global VID => FID mapping we created when the -* FID was configured. -*/ -if (mlxsw_sp->fid_core->port_fid_mappings[local_port] ==0 ) -return 0 ; -return __mlxsw_sp_fid_port_vid_map (mlxsw_sp, fid->fid_index, local_port, - vid, true); -} - -static void -mlxsw_sp_fid_8021q_port_vid_unmap (struct mlxsw_sp_fid *fid, -struct mlxsw_sp_port *mlxsw_sp_port,u16 vid) -{ -struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; -u8 local_port = mlxsw_sp_port->local_port; - -if (mlxsw_sp->fid_core->port_fid_mappings[local_port] ==0 ) -return ; -__mlxsw_sp_fid_port_vid_map (mlxsw_sp, fid->fid_index, local_port, vid, - false); -} - -static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_8021q_ops = { - .setup = mlxsw_sp_fid_8021q_setup, - .configure = mlxsw_sp_fid_8021q_configure, - .deconfigure = mlxsw_sp_fid_8021q_deconfigure, - .index_alloc = mlxsw_sp_fid_8021q_index_alloc, - .compare = mlxsw_sp_fid_8021q_compare, - .flood_index = mlxsw_sp_fid_8021q_flood_index, - .port_vid_map = mlxsw_sp_fid_8021q_port_vid_map, - .port_vid_unmap = mlxsw_sp_fid_8021q_port_vid_unmap, -}; - -static const struct mlxsw_sp_flood_table mlxsw_sp_fid_8021q_flood_tables[] = { - { - .packet_type =MLXSW_SP_FLOOD_TYPE_UC , - .bridge_type =MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID , - .table_type =MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET , - .table_index =0 , - }, - { - .packet_type =MLXSW_SP_FLOOD_TYPE_MC , - .bridge_type =MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID , - .table_type =MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET , - .table_index =1 , - }, - { - .packet_type =MLXSW_SP_FLOOD_TYPE_BC , - .bridge_type =MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID , - .table_type =MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET , - .table_index =2 , - }, -}; - -/* Range and flood configuration must match mlxsw_config_profile */ -static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021q_family = { - .type =MLXSW_SP_FID_TYPE_8021Q , - .fid_size =sizeof (struct mlxsw_sp_fid_8021q ), - .start_index =1 , - .end_index =VLAN_VID_MASK , - .flood_tables = mlxsw_sp_fid_8021q_flood_tables, - .nr_flood_tables =ARRAY_SIZE (mlxsw_sp_fid_8021q_flood_tables), - .rif_type =MLXSW_SP_RIF_TYPE_VLAN , - .ops = &mlxsw_sp_fid_8021q_ops, -}; -static struct mlxsw_sp_fid_8021d *mlxsw_sp_fid_8021d_fid (const struct mlxsw_sp_fid *fid) {
@@ -846,6 +702,14 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021d_family = { .lag_vid_valid = 1, }; +static bool +mlxsw_sp_fid_8021q_compare (const struct mlxsw_sp_fid *fid,const void *arg) +{ +u16 vid = *(u16 *) arg; + +return mlxsw_sp_fid_8021q_fid (fid)->vid == vid; +} +static void mlxsw_sp_fid_8021q_fdb_clear_offload (const struct mlxsw_sp_fid *fid,const struct net_device *nve_dev)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +39 -104
177 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 4/6 mlxsw: core_acl: Avoid defining static variable in header file
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
The static array 'mlxsw_afk_element_infos' in 'core_acl_flex_keys.h' is copied to each file that includes the header, but not all use it. This results in the following warnings when compiling with W=1:
drivers/net/ethernet/mellanox/mlxsw//core_acl_flex_keys.h:76:44:
warning: ‘mlxsw_afk_element_infos’ defined but not used [-Wunused-const-variable=]
One way to suppress the warning is to mark the array with '__maybe_unused', but another option is to remove it from the header file entirely.
Change 'struct mlxsw_afk_element_inst' to store the key to the array ('element') instead of the array value keyed by 'element'. Adjust the different users accordingly.
--- .../mellanox/mlxsw/core_acl_flex_keys.c | 50 +++++++++++++++++-- .../mellanox/mlxsw/core_acl_flex_keys.h | 36 +------------ 2 files changed, 47 insertions(+), 39 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +45 -5
@@ -9,6 +9,41 @@#include "item.h" #include "core_acl_flex_keys.h" +/* For the purpose of the driver, define an internal storage scratchpad +* that will be used to store key/mask values. For each defined element type +* define an internal storage geometry. +* +* When adding new elements, MLXSW_AFK_ELEMENT_STORAGE_SIZE must be increased +* accordingly. +*/ +static const struct mlxsw_afk_element_info mlxsw_afk_element_infos[] = { +MLXSW_AFK_ELEMENT_INFO_U32 (SRC_SYS_PORT ,0x00 ,16 ,16 ), +MLXSW_AFK_ELEMENT_INFO_BUF (DMAC_32_47 ,0x04 ,2 ), +MLXSW_AFK_ELEMENT_INFO_BUF (DMAC_0_31 ,0x06 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (SMAC_32_47 ,0x0A ,2 ), +MLXSW_AFK_ELEMENT_INFO_BUF (SMAC_0_31 ,0x0C ,4 ), +MLXSW_AFK_ELEMENT_INFO_U32 (ETHERTYPE ,0x00 ,0 ,16 ), +MLXSW_AFK_ELEMENT_INFO_U32 (IP_PROTO ,0x10 ,0 ,8 ), +MLXSW_AFK_ELEMENT_INFO_U32 (VID ,0x10 ,8 ,12 ), +MLXSW_AFK_ELEMENT_INFO_U32 (PCP ,0x10 ,20 ,3 ), +MLXSW_AFK_ELEMENT_INFO_U32 (TCP_FLAGS ,0x10 ,23 ,9 ), +MLXSW_AFK_ELEMENT_INFO_U32 (DST_L4_PORT ,0x14 ,0 ,16 ), +MLXSW_AFK_ELEMENT_INFO_U32 (SRC_L4_PORT ,0x14 ,16 ,16 ), +MLXSW_AFK_ELEMENT_INFO_U32 (IP_TTL_ ,0x18 ,0 ,8 ), +MLXSW_AFK_ELEMENT_INFO_U32 (IP_ECN ,0x18 ,9 ,2 ), +MLXSW_AFK_ELEMENT_INFO_U32 (IP_DSCP ,0x18 ,11 ,6 ), +MLXSW_AFK_ELEMENT_INFO_U32 (VIRT_ROUTER_8_10 ,0x18 ,17 ,3 ), +MLXSW_AFK_ELEMENT_INFO_U32 (VIRT_ROUTER_0_7 ,0x18 ,20 ,8 ), +MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_96_127 ,0x20 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_64_95 ,0x24 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_32_63 ,0x28 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_0_31 ,0x2C ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_96_127 ,0x30 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_64_95 ,0x34 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_32_63 ,0x38 ,4 ), +MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_0_31 ,0x3C ,4 ), +}; +struct mlxsw_afk {struct list_head key_info_list;unsigned int max_blocks;
@@ -26,13 +61,15 @@ static bool mlxsw_afk_blocks_check(struct mlxsw_afk *mlxsw_afk)const struct mlxsw_afk_block *block = &mlxsw_afk->blocks[i];for (j =0 ; j < block->instances_count; j++) { +const struct mlxsw_afk_element_info *elinfo;struct mlxsw_afk_element_inst *elinst; elinst = &block->instances[j]; -if (elinst->type != elinst->info->type || + elinfo = &mlxsw_afk_element_infos[elinst->element]; +if (elinst->type != elinfo->type || (!elinst->avoid_size_check && elinst->item.size.bits != - elinst->info->item.size.bits)) + elinfo->item.size.bits))return false; } }
@@ -116,7 +153,7 @@ static void mlxsw_afk_picker_count_hits(struct mlxsw_afk *mlxsw_afk,struct mlxsw_afk_element_inst *elinst; elinst = &block->instances[j]; -if (elinst->info->element == element) { +if (elinst->element == element) {__set_bit (element, picker->hits[i].element); picker->hits[i].total++; }
@@ -301,7 +338,7 @@ mlxsw_afk_block_elinst_get(const struct mlxsw_afk_block *block,struct mlxsw_afk_element_inst *elinst; elinst = &block->instances[i]; -if (elinst->info->element == element) +if (elinst->element == element)return elinst; }return NULL ;
@@ -409,9 +446,12 @@ static void mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst, char *output, char *storage, int u32_diff) { - const struct mlxsw_item *storage_item = &elinst->info->item; const struct mlxsw_item *output_item = &elinst->item; +const struct mlxsw_afk_element_info *elinfo; +const struct mlxsw_item *storage_item; + elinfo = &mlxsw_afk_element_infos[elinst->element]; + storage_item = &elinfo->item;if (elinst->type ==MLXSW_AFK_ELEMENT_TYPE_U32 )mlxsw_sp_afk_encode_u32 (storage_item, output_item, storage, output, u32_diff);
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h +2 -34
@@ -69,42 +69,10 @@ struct mlxsw_afk_element_info {MLXSW_AFK_ELEMENT_INFO (MLXSW_AFK_ELEMENT_TYPE_BUF , \ _element, _offset, 0, _size) -/* For the purpose of the driver, define an internal storage scratchpad -* that will be used to store key/mask values. For each defined element type -* define an internal storage geometry. - */ -static const struct mlxsw_afk_element_info mlxsw_afk_element_infos[] = { -MLXSW_AFK_ELEMENT_INFO_U32 (SRC_SYS_PORT ,0x00 ,16 ,16 ), -MLXSW_AFK_ELEMENT_INFO_BUF (DMAC_32_47 ,0x04 ,2 ), -MLXSW_AFK_ELEMENT_INFO_BUF (DMAC_0_31 ,0x06 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (SMAC_32_47 ,0x0A ,2 ), -MLXSW_AFK_ELEMENT_INFO_BUF (SMAC_0_31 ,0x0C ,4 ), -MLXSW_AFK_ELEMENT_INFO_U32 (ETHERTYPE ,0x00 ,0 ,16 ), -MLXSW_AFK_ELEMENT_INFO_U32 (IP_PROTO ,0x10 ,0 ,8 ), -MLXSW_AFK_ELEMENT_INFO_U32 (VID ,0x10 ,8 ,12 ), -MLXSW_AFK_ELEMENT_INFO_U32 (PCP ,0x10 ,20 ,3 ), -MLXSW_AFK_ELEMENT_INFO_U32 (TCP_FLAGS ,0x10 ,23 ,9 ), -MLXSW_AFK_ELEMENT_INFO_U32 (DST_L4_PORT ,0x14 ,0 ,16 ), -MLXSW_AFK_ELEMENT_INFO_U32 (SRC_L4_PORT ,0x14 ,16 ,16 ), -MLXSW_AFK_ELEMENT_INFO_U32 (IP_TTL_ ,0x18 ,0 ,8 ), -MLXSW_AFK_ELEMENT_INFO_U32 (IP_ECN ,0x18 ,9 ,2 ), -MLXSW_AFK_ELEMENT_INFO_U32 (IP_DSCP ,0x18 ,11 ,6 ), -MLXSW_AFK_ELEMENT_INFO_U32 (VIRT_ROUTER_8_10 ,0x18 ,17 ,3 ), -MLXSW_AFK_ELEMENT_INFO_U32 (VIRT_ROUTER_0_7 ,0x18 ,20 ,8 ), -MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_96_127 ,0x20 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_64_95 ,0x24 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_32_63 ,0x28 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (SRC_IP_0_31 ,0x2C ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_96_127 ,0x30 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_64_95 ,0x34 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_32_63 ,0x38 ,4 ), -MLXSW_AFK_ELEMENT_INFO_BUF (DST_IP_0_31 ,0x3C ,4 ), -}; -#define MLXSW_AFK_ELEMENT_STORAGE_SIZE 0x40struct mlxsw_afk_element_inst {/* element instance in actual block */ -const struct mlxsw_afk_element_info *info; +enum mlxsw_afk_element element;enum mlxsw_afk_element_type type;struct mlxsw_item item;/* element geometry in block */ int u32_key_diff;/* in case value needs to be adjusted before write
@@ -116,7 +84,7 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */#define MLXSW_AFK_ELEMENT_INST (_type, _element, _offset, \ _shift, _size, _u32_key_diff, _avoid_size_check) \ { \ - .info = &mlxsw_afk_element_infos[MLXSW_AFK_ELEMENT_##_element], \ + .element = MLXSW_AFK_ELEMENT_##_element, \ .type = _type, \ .item = { \ .offset = _offset, \
Signature · 1 line
2.24.1
PATCH 5/6 mlxsw: switchx2: Remove unnecessary conversion to bool
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Suppress following warning from coccinelle:
drivers/net/ethernet/mellanox/mlxsw//switchx2.c:183:63-68: WARNING:
conversion to bool not needed here
--- drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/switchx2.c +1 -1
@@ -180,7 +180,7 @@ static int mlxsw_sx_port_oper_status_get(struct mlxsw_sx_port *mlxsw_sx_port,if (err)return err; oper_status =mlxsw_reg_paos_oper_status_get (paos_pl); - *p_is_up = oper_status ==MLXSW_PORT_ADMIN_STATUS_UP ? true : false; + *p_is_up = oper_status ==MLXSW_PORT_ADMIN_STATUS_UP ;return 0 ; }
Signature · 1 line
2.24.1
PATCH 6/6 mlxsw: spectrum_router: Avoid uninitialized symbol errors
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Suppress the following smatch errors. None of these are actually possible with current code paths.
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1220 mlxsw_sp_ipip_entry_find_decap() error: uninitialized symbol 'saddrp'. drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1220 mlxsw_sp_ipip_entry_find_decap() error: uninitialized symbol 'saddr_len'. drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1221 mlxsw_sp_ipip_entry_find_decap() error: uninitialized symbol 'saddr_prefix_len'.
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1390 mlxsw_sp_netdevice_ipip_ol_reg_event() error: uninitialized symbol 'ipipt'.
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3255 mlxsw_sp_nexthop_group_update() error: uninitialized symbol 'err'.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +4 -3
@@ -1212,7 +1212,7 @@ mlxsw_sp_ipip_entry_find_decap(struct mlxsw_sp *mlxsw_sp, saddr_len =4 ; saddr_prefix_len =32 ;break ; -case MLXSW_SP_L3_PROTO_IPV6 : +default :WARN_ON (1 );return NULL ; }
@@ -1380,9 +1380,9 @@ static bool mlxsw_sp_netdevice_ipip_can_offload(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_netdevice_ipip_ol_reg_event (struct mlxsw_sp *mlxsw_sp,struct net_device *ol_dev) { +enum mlxsw_sp_ipip_type ipipt =MLXSW_SP_IPIP_TYPE_MAX ;struct mlxsw_sp_ipip_entry *ipip_entry;enum mlxsw_sp_l3proto ul_proto; -enum mlxsw_sp_ipip_type ipipt;union mlxsw_sp_l3addr saddr;u32 ul_tb_id;
@@ -3231,7 +3231,6 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,u32 adj_index = nh_grp->adj_index;/* base */ struct mlxsw_sp_nexthop *nh;int i; -int err;for (i =0 ; i < nh_grp->count; i++) { nh = &nh_grp->nexthops[i];
@@ -3242,6 +3241,8 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp, }if (nh->update || reallocate) { +int err =0 ; +switch (nh->type) {case MLXSW_SP_NEXTHOP_TYPE_ETH : err = mlxsw_sp_nexthop_update
Signature · 1 line
2.24.1
David Miller
maintainerFrom: Ido Schimmel <[email protected]>
Date: Fri, 27 Mar 2020 11:55:19 +0300
Quoted 11 lines
From: Ido Schimmel <[email protected]>
Jakub told me he gets some warnings with W=1, so I decided to check with sparse, smatch and coccinelle as well. This patch set fixes all the issues found. None are actual bugs / regressions and therefore not targeted at net.
Patches #1-#2 add missing kernel-doc comments.
Patch #3 removes dead code.
Quoted 8 lines
Patch #4 reworks the ACL code to avoid defining a static variable in a header file.
Patch #5 removes unnecessary conversion to bool that coccinelle warns about.
Patch #6 avoids false-positive uninitialized symbol errors emitted by smatch.
Series applied, thanks Ido.