@@ -973,7 +973,6 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context,
int ether_len;
struct peer_address src;
struct peer_address dst;
- uint16_t ret_vid;
int ret = -EINVAL;
int err;
@@ -1022,10 +1021,11 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context,
goto free_resources;
if (vid) {
- ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler);
+ uint16_t ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler);
if (ret_vid <= 0xfff)
neigh_set_vlan_id(&neigh_handler, ret_vid);
+ *vid = ret_vid;
}
/* We are using only Ethernet here */
@@ -1036,9 +1036,6 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context,
if (ether_len <= 0)
goto free_resources;
- if (vid)
- *vid = ret_vid;
-
ret = 0;
free_resources:
gcc 10 with LTO reports: ../libibverbs/verbs.c:1040:8: error: 'ret_vid' may be used uninitialized in this function [-Werror=maybe-uninitialized] 1040 | *vid = ret_vid; Which seems like a compiler bug as there is obviously no way for this to be true, nor is it clear how LTO has any impact here since neigh_get_vlan_id_from_dev() always returns a defined value. Nevertheless, the logic is tortured, so simplify it by combining everything into one if. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- libibverbs/verbs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)