All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/cma: silence GCC warning
@ 2013-07-15 11:03 ` Paul Bolle
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Bolle @ 2013-07-15 11:03 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA

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".

Help GCC by initializing "port" to 0. Since valid port numbers
apparently start at 1, this is an invalid value. That could help in
analyzing the code and tracking down errors.

Signed-off-by: Paul Bolle <pebolle-IWqWACnzNjzz+pZb47iToQ@public.gmane.org>
---
0) Compile tested only.

1) Perhaps a better way to silence GCC is to drop "port" entirely, and
assign to "id_priv->id.port_num" directly. Would that be acceptable?

 drivers/infiniband/core/cma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index f1c279f..c6c0a5f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -426,6 +426,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
 	u8 port, p;
 	int i;
 
+	port = 0; /* silence GCC */
 	cma_dev = NULL;
 	addr = (struct sockaddr_ib *) cma_dst_addr(id_priv);
 	dgid = (union ib_gid *) &addr->sib_addr;
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] RDMA/cma: silence GCC warning
@ 2013-07-15 11:03 ` Paul Bolle
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Bolle @ 2013-07-15 11:03 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock; +Cc: linux-rdma, linux-kernel

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".

Help GCC by initializing "port" to 0. Since valid port numbers
apparently start at 1, this is an invalid value. That could help in
analyzing the code and tracking down errors.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
0) Compile tested only.

1) Perhaps a better way to silence GCC is to drop "port" entirely, and
assign to "id_priv->id.port_num" directly. Would that be acceptable?

 drivers/infiniband/core/cma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index f1c279f..c6c0a5f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -426,6 +426,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
 	u8 port, p;
 	int i;
 
+	port = 0; /* silence GCC */
 	cma_dev = NULL;
 	addr = (struct sockaddr_ib *) cma_dst_addr(id_priv);
 	dgid = (union ib_gid *) &addr->sib_addr;
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH] RDMA/cma: silence GCC warning
  2013-07-15 11:03 ` Paul Bolle
@ 2013-07-15 21:08     ` Hefty, Sean
  -1 siblings, 0 replies; 7+ messages in thread
From: Hefty, Sean @ 2013-07-15 21:08 UTC (permalink / raw)
  To: Paul Bolle, Roland Dreier, Hal Rosenstock
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA

> 1) Perhaps a better way to silence GCC is to drop "port" entirely, and
> assign to "id_priv->id.port_num" directly. Would that be acceptable?

Yes, this would work.

- Sean
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] RDMA/cma: silence GCC warning
@ 2013-07-15 21:08     ` Hefty, Sean
  0 siblings, 0 replies; 7+ messages in thread
From: Hefty, Sean @ 2013-07-15 21:08 UTC (permalink / raw)
  To: Paul Bolle, Roland Dreier, Hal Rosenstock; +Cc: linux-rdma, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 337 bytes --]

> 1) Perhaps a better way to silence GCC is to drop "port" entirely, and
> assign to "id_priv->id.port_num" directly. Would that be acceptable?

Yes, this would work.

- Sean
 
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] RDMA/cma: silence GCC warning
  2013-07-15 21:08     ` Hefty, Sean
  (?)
@ 2013-07-17  8:40     ` Paul Bolle
       [not found]       ` <1374050453.26384.41.camel-uMdlDhfIn7prKue/0VVhAg@public.gmane.org>
  -1 siblings, 1 reply; 7+ messages in thread
From: Paul Bolle @ 2013-07-17  8:40 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock; +Cc: linux-rdma, linux-kernel

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>
---
0) v2: assign to "id_priv->id.port_num" directly, instead of
initializing "port" to 0, as discussed with Sean.

1) Still only compile tested.

 drivers/infiniband/core/cma.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index f1c279f..84487a2 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -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;
@@ -443,7 +443,7 @@ 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;
 				}
 
@@ -451,7 +451,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
 						 dgid->global.subnet_prefix)) {
 					cma_dev = cur_dev;
 					sgid = gid;
-					port = p;
+					id_priv->id.port_num = p;
 				}
 			}
 		}
@@ -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);
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH v2] RDMA/cma: silence GCC warning
  2013-07-17  8:40     ` [PATCH v2] " Paul Bolle
@ 2013-07-17 18:07           ` Hefty, Sean
  0 siblings, 0 replies; 7+ messages in thread
From: Hefty, Sean @ 2013-07-17 18:07 UTC (permalink / raw)
  To: Paul Bolle, Roland Dreier, Hal Rosenstock
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 955 bytes --]

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

Acked-by: Sean Hefty <sean.hefty@intel.com>

> ---
> 0) v2: assign to "id_priv->id.port_num" directly, instead of
> initializing "port" to 0, as discussed with Sean.
> 
> 1) Still only compile tested.

tested - thanks
N‹§²æìr¸›yúèšØb²X¬¶Ç§vØ^–)Þº{.nÇ+‰·¥Š{±­ÙšŠ{ayº\x1dʇڙë,j\a­¢f£¢·hš‹»öì\x17/oSc¾™Ú³9˜uÀ¦æå‰È&jw¨®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿïêäz¹Þ–Šàþf£¢·hšˆ§~ˆmš

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v2] RDMA/cma: silence GCC warning
@ 2013-07-17 18:07           ` Hefty, Sean
  0 siblings, 0 replies; 7+ messages in thread
From: Hefty, Sean @ 2013-07-17 18:07 UTC (permalink / raw)
  To: Paul Bolle, Roland Dreier, Hal Rosenstock; +Cc: linux-rdma, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 961 bytes --]

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

Acked-by: Sean Hefty <sean.hefty@intel.com>

> ---
> 0) v2: assign to "id_priv->id.port_num" directly, instead of
> initializing "port" to 0, as discussed with Sean.
> 
> 1) Still only compile tested.

tested - thanks
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-07-17 18:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15 11:03 [PATCH] RDMA/cma: silence GCC warning Paul Bolle
2013-07-15 11:03 ` Paul Bolle
     [not found] ` <1373886239.2591.26.camel-uMdlDhfIn7prKue/0VVhAg@public.gmane.org>
2013-07-15 21:08   ` Hefty, Sean
2013-07-15 21:08     ` Hefty, Sean
2013-07-17  8:40     ` [PATCH v2] " Paul Bolle
     [not found]       ` <1374050453.26384.41.camel-uMdlDhfIn7prKue/0VVhAg@public.gmane.org>
2013-07-17 18:07         ` Hefty, Sean
2013-07-17 18:07           ` Hefty, Sean

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.