* Janz ICAN3 build warnings
@ 2014-01-29 14:10 Oliver Hartkopp
2014-01-29 17:58 ` Ira W. Snyder
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Hartkopp @ 2014-01-29 14:10 UTC (permalink / raw)
To: Ira W. Snyder, linux-can@vger.kernel.org
Hello Ira,
while addressing an issue with the skb->sk handling here
http://marc.info/?l=linux-netdev&m=139100313304453&w=2
I was enabling the Janz ICAN3 driver to be built as I did a small change
there too.
Can you please fix these build warnings below?
Regards,
Oliver
CC [M] drivers/net/can/janz-ican3.o
drivers/net/can/janz-ican3.c:1086:43: warning: ‘msg.data[6]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
mod->termination_enabled = msg->data[6] & HWCONF_TERMINATE_ON;
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.data[6]’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:1067:15: warning: ‘msg.data[5]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cf->data[6] = txerr;
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.data[5]’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:1068:15: warning: ‘msg.data[4]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cf->data[7] = rxerr;
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.data[4]’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:1014:21: warning: ‘msg.data[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
} else if (status & SR_ES) {
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.data[3]’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:1045:13: warning: ‘msg.data[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (!(ecc & ECC_DIR))
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.data[2]’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:940:5: warning: ‘msg.data[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (msg->data[1] != CEVTIND_CHIP_SJA1000) {
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.data[1]’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:1025:5: warning: ‘*((void *)&msg+4)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (isrc == CEVTIND_BEI) {
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘*((void *)&msg+4)’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:1098:10: warning: ‘msg.len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
dev_warn(mod->dev, "received unknown message: spec 0x%.2x length %d\n",
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.len’ was declared here
struct ican3_msg msg;
^
drivers/net/can/janz-ican3.c:900:5: warning: ‘msg.spec’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (msg->spec == MSG_MSGLOST) {
^
drivers/net/can/janz-ican3.c:1320:20: note: ‘msg.spec’ was declared here
struct ican3_msg msg;
^
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Janz ICAN3 build warnings
2014-01-29 14:10 Janz ICAN3 build warnings Oliver Hartkopp
@ 2014-01-29 17:58 ` Ira W. Snyder
2014-01-29 19:14 ` Oliver Hartkopp
2014-01-29 20:30 ` Marc Kleine-Budde
0 siblings, 2 replies; 4+ messages in thread
From: Ira W. Snyder @ 2014-01-29 17:58 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: linux-can@vger.kernel.org
From 90dd8d23b90d837d8d2bc5d53d0319b15f1db5a8 Mon Sep 17 00:00:00 2001
From: "Ira W. Snyder" <iws@ovro.caltech.edu>
Date: Wed, 29 Jan 2014 09:51:48 -0800
Subject: [PATCH] can: janz-ican3: fix uninitialized variable warnings
Analysis of the code shows that the struct ican3_msg variable cannot be
used uninitialized. Error conditions are checked and the loop terminates
before calling the ican3_handle_message() function with an uninitialized
value.
Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
---
Hi Oliver, it looks like GCC is being stupid here. The loop obviously
terminates before calling ican3_handle_message(). Do you agree?
I can't reproduce these warnings. Can you apply this patch and see if it
fixes the problem for your compiler version? If so, go ahead and apply
it.
Thanks,
Ira
drivers/net/can/janz-ican3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index e24e6690d672..07f0ba03cd59 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -1322,7 +1322,7 @@ static int ican3_napi(struct napi_struct *napi, int budget)
/* process all communication messages */
while (true) {
- struct ican3_msg msg;
+ struct ican3_msg uninitialized_var(msg);
ret = ican3_recv_msg(mod, &msg);
if (ret)
break;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Janz ICAN3 build warnings
2014-01-29 17:58 ` Ira W. Snyder
@ 2014-01-29 19:14 ` Oliver Hartkopp
2014-01-29 20:30 ` Marc Kleine-Budde
1 sibling, 0 replies; 4+ messages in thread
From: Oliver Hartkopp @ 2014-01-29 19:14 UTC (permalink / raw)
To: Ira W. Snyder; +Cc: linux-can@vger.kernel.org
On 29.01.2014 18:58, Ira W. Snyder wrote:
> From 90dd8d23b90d837d8d2bc5d53d0319b15f1db5a8 Mon Sep 17 00:00:00 2001
> From: "Ira W. Snyder" <iws@ovro.caltech.edu>
> Date: Wed, 29 Jan 2014 09:51:48 -0800
> Subject: [PATCH] can: janz-ican3: fix uninitialized variable warnings
>
> Analysis of the code shows that the struct ican3_msg variable cannot be
> used uninitialized. Error conditions are checked and the loop terminates
> before calling the ican3_handle_message() function with an uninitialized
> value.
>
> Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
Yes, that fixed it!
Thanks for your fast response!
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
> ---
>
> Hi Oliver, it looks like GCC is being stupid here. The loop obviously
> terminates before calling ican3_handle_message(). Do you agree?
>
> I can't reproduce these warnings. Can you apply this patch and see if it
> fixes the problem for your compiler version? If so, go ahead and apply
> it.
>
> Thanks,
> Ira
>
> drivers/net/can/janz-ican3.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
> index e24e6690d672..07f0ba03cd59 100644
> --- a/drivers/net/can/janz-ican3.c
> +++ b/drivers/net/can/janz-ican3.c
> @@ -1322,7 +1322,7 @@ static int ican3_napi(struct napi_struct *napi, int budget)
>
> /* process all communication messages */
> while (true) {
> - struct ican3_msg msg;
> + struct ican3_msg uninitialized_var(msg);
> ret = ican3_recv_msg(mod, &msg);
> if (ret)
> break;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Janz ICAN3 build warnings
2014-01-29 17:58 ` Ira W. Snyder
2014-01-29 19:14 ` Oliver Hartkopp
@ 2014-01-29 20:30 ` Marc Kleine-Budde
1 sibling, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2014-01-29 20:30 UTC (permalink / raw)
To: Ira W. Snyder, Oliver Hartkopp; +Cc: linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 899 bytes --]
On 01/29/2014 06:58 PM, Ira W. Snyder wrote:
> From 90dd8d23b90d837d8d2bc5d53d0319b15f1db5a8 Mon Sep 17 00:00:00 2001
> From: "Ira W. Snyder" <iws@ovro.caltech.edu>
> Date: Wed, 29 Jan 2014 09:51:48 -0800
> Subject: [PATCH] can: janz-ican3: fix uninitialized variable warnings
>
> Analysis of the code shows that the struct ican3_msg variable cannot be
> used uninitialized. Error conditions are checked and the loop terminates
> before calling the ican3_handle_message() function with an uninitialized
> value.
>
> Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
Applied to can/master.
Tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-29 20:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-29 14:10 Janz ICAN3 build warnings Oliver Hartkopp
2014-01-29 17:58 ` Ira W. Snyder
2014-01-29 19:14 ` Oliver Hartkopp
2014-01-29 20:30 ` Marc Kleine-Budde
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.