Skip to contentSkip to conversation

net: sparx5: Refactor mdb handling according to feedback

bug report Dan Carpenter 1 participant 1 message Aug 18, 2022 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hello Casper Andersson,

The patch ad238fc6de7d: "net: sparx5: Refactor mdb handling according to feedback" from Mar 24, 2022, leads to the following Smatch static checker warning:

drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c:215 sparx5_mact_find()
warn: potential negative cast to bool 'ret'

drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c

    189 bool sparx5_mact_find(struct sparx5 *sparx5,
    190                       const unsigned char mac[ETH_ALEN], u16 vid, u32 *pcfg2)
    191 {
    192         int ret;
    193         u32 cfg2;
    194 
    195         mutex_lock(&sparx5->lock);
    196 
    197         sparx5_mact_select(sparx5, mac, vid);
    198 
    199         /* Issue a lookup command */
    200         spx5_wr(LRN_COMMON_ACCESS_CTRL_CPU_ACCESS_CMD_SET(MAC_CMD_LOOKUP) |
    201                 LRN_COMMON_ACCESS_CTRL_MAC_TABLE_ACCESS_SHOT_SET(1),
    202                 sparx5, LRN_COMMON_ACCESS_CTRL);
    203 
    204         ret = sparx5_mact_wait_for_completion(sparx5);
    205         if (ret == 0) {
    206                 cfg2 = spx5_rd(sparx5, LRN_MAC_ACCESS_CFG_2);
    207                 if (LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_VLD_GET(cfg2))
    208                         *pcfg2 = cfg2;
    209                 else
    210                         ret = -ENOENT;

ret is set to -ENOENT but this function returns bool. I guess it returns true for failure and false for success? So this isn't a bug but it's super confusing.

    211         }
    212 
    213         mutex_unlock(&sparx5->lock);
    214 
--> 215         return ret;
    216 }

regards,
dan carpenter