All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: <linux-rdma@vger.kernel.org>
Subject: [PATCH 2/4] verbs: Simplify the logic assigning vid in ibv_resolve_eth_l2_from_gid()
Date: Mon, 16 Nov 2020 16:16:14 -0400	[thread overview]
Message-ID: <2-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> (raw)
In-Reply-To: <0-v1-f03f70229014+144-fix_lto_jgg@nvidia.com>

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(-)

diff --git a/libibverbs/verbs.c b/libibverbs/verbs.c
index 7fc10240cf9def..2b0ede84e8d635 100644
--- a/libibverbs/verbs.c
+++ b/libibverbs/verbs.c
@@ -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:
-- 
2.29.2


  parent reply	other threads:[~2020-11-16 20:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 20:16 [PATCH 0/4] Enable LTO support for rdma-core Jason Gunthorpe
2020-11-16 20:16 ` [PATCH 1/4] libibumad: Check for error returns in get_port() Jason Gunthorpe
2020-11-16 20:16 ` Jason Gunthorpe [this message]
2020-11-16 20:16 ` [PATCH 3/4] iwpmd: Always copy the ss_family in copy_iwpm_sockaddr() Jason Gunthorpe
2020-11-16 20:16 ` [PATCH 4/4] util: Use GCC 10's attribute symver to define compat symbol versions Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2-v1-f03f70229014+144-fix_lto_jgg@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.