Skip to content

Commit

Permalink
RDMA/cma: Fix gcc warning
Browse files Browse the repository at this point in the history
Building cma.o triggers this gcc warning:

    drivers/infiniband/core/cma.c: In function ‘rdma_resolve_addr’:
    drivers/infiniband/core/cma.c:465:23: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    drivers/infiniband/core/cma.c:426:5: note: ‘port’ was declared here

This is a false positive, as "port" will always be initialized if we're
at "found". But if we assign to "id_priv->id.port_num" directly, we can
drop "port". That will, obviously, silence gcc.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
  • Loading branch information
Paul Bolle authored and Roland Dreier committed Jul 30, 2013
1 parent 3b2f64d commit 8fb488d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
struct sockaddr_ib *addr;
union ib_gid gid, sgid, *dgid;
u16 pkey, index;
u8 port, p;
u8 p;
int i;

cma_dev = NULL;
Expand All @@ -443,15 +443,15 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
if (!memcmp(&gid, dgid, sizeof(gid))) {
cma_dev = cur_dev;
sgid = gid;
port = p;
id_priv->id.port_num = p;
goto found;
}

if (!cma_dev && (gid.global.subnet_prefix ==
dgid->global.subnet_prefix)) {
cma_dev = cur_dev;
sgid = gid;
port = p;
id_priv->id.port_num = p;
}
}
}
Expand All @@ -462,7 +462,6 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)

found:
cma_attach_to_dev(id_priv, cma_dev);
id_priv->id.port_num = port;
addr = (struct sockaddr_ib *) cma_src_addr(id_priv);
memcpy(&addr->sib_addr, &sgid, sizeof sgid);
cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
Expand Down

0 comments on commit 8fb488d

Please sign in to comment.