Skip to contentSkip to conversation

char: fix sparse variable shadowing and int as NULL pointer in rocket.c

PATCH In review Harvey Harrison 2 participants 4 messages Feb 22, 2008 – Feb 27, 2008 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 char: fix sparse variable shadowing and int as NULL pointer in rocket.c

Nested min() macros shadow _x, separate into two lines. drivers/char/rocket.c:451:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:451:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:451:7: warning: symbol '_y' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_y' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1751:20: warning: Using plain integer as NULL pointer

---
 drivers/char/rocket.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/rocket.c +5 -4
index 72f2892..2778d64 100644
@@ -448,7 +448,8 @@ static void rp_do_transmit(struct r_port *info)
 	while (1) {
 		if (tty->stopped || tty->hw_stopped)
 			break;
-		c = min(info->xmit_fifo_room, min(info->xmit_cnt, XMIT_BUF_SIZE - info->xmit_tail));
+		c = min(info->xmit_fifo_room, info->xmit_cnt);
+		c = min(c, XMIT_BUF_SIZE - info->xmit_tail);
 		if (c <= 0 || info->xmit_fifo_room <= 0)
 			break;
 		sOutStrW(sGetTxRxDataIO(cp), (unsigned short *) (info->xmit_buf + info->xmit_tail), c / 2);
@@ -1748,10 +1749,10 @@ static int rp_write(struct tty_struct *tty,
 
 	/*  Write remaining data into the port's xmit_buf */
 	while (1) {
-		if (info->tty == 0)	/*   Seemingly obligatory check... */
+		if (info->tty == NULL)	/*   Seemingly obligatory check... */
 			goto end;
-
-		c = min(count, min(XMIT_BUF_SIZE - info->xmit_cnt - 1, XMIT_BUF_SIZE - info->xmit_head));
+		c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1);
+		c = min(c, XMIT_BUF_SIZE - info->xmit_head);
 		if (c <= 0)
 			break;
 
Signature · 1 line
1.5.4.2.200.g99e75
#1 lore raw
Quoted 3 lines · On Fri, 22 Feb 2008 09:46:59 -0800 Harvey Harrison <[email protected]>…

Subject: [PATCH] char: fix sparse variable shadowing and int as NULL pointer in rocket.c

Please try to make the patch titles big-endian. This one could have been

char: rocket.c: fix sparse variable shadowing and int as NULL pointer

or even

rocket.c: fix sparse variable shadowing and int as NULL pointer

Quoted 6 lines

Nested min() macros shadow _x, separate into two lines. drivers/char/rocket.c:451:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:451:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:451:7: warning: symbol '_y' shadows an earlier one

Quoted 9 lines

drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_y' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1751:20: warning: Using plain integer as NULL pointer

That's really a sparse glitch. There's nothing we can sanely do about it.

Quoted 9 lines
---
 drivers/char/rocket.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/rocket.c +0 -0
index 72f2892..2778d64 100644

drivers/char/rocket.c static void rp_do_transmit(struct r_port *info) · line 452

Quoted 6 lines
drivers/char/rocket.c +2 -1
@@ -448,7 +448,8 @@ static void rp_do_transmit(struct r_port *info)
 	while (1) {
 		if (tty->stopped || tty->hw_stopped)
 			break;
-		c = min(info->xmit_fifo_room, min(info->xmit_cnt, XMIT_BUF_SIZE - info->xmit_tail));
+		c = min(info->xmit_fifo_room, info->xmit_cnt);
+		c = min(c, XMIT_BUF_SIZE - info->xmit_tail);

Apart from things like that.

Probably this code is cleaner than the old version so let's do it, but it seems that we need a general fix.

#2 lore raw
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Fri, 22 Feb 2008 09:46:59 -0800 Harvey Harrison <[email protected]>…

Subject: [PATCH] char: fix sparse variable shadowing and int as NULL pointer in rocket.c

Please try to make the patch titles big-endian. This one could have been

char: rocket.c: fix sparse variable shadowing and int as NULL pointer

OK.

Quoted 20 lines

or even

rocket.c: fix sparse variable shadowing and int as NULL pointer

Quoted 6 lines

Nested min() macros shadow _x, separate into two lines. drivers/char/rocket.c:451:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:451:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:451:7: warning: symbol '_y' shadows an earlier one

Quoted 9 lines

drivers/char/rocket.c:451:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_x' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1754:7: warning: symbol '_y' shadows an earlier one drivers/char/rocket.c:1754:7: originally declared here drivers/char/rocket.c:1751:20: warning: Using plain integer as NULL pointer

Quoted 2 lines

That's really a sparse glitch. There's nothing we can sanely do about it.

Well, we can at least get rid of the warnings when min/max are nested. I sent you a patch earlier today that uses different temp variables in min/max/min_t/max_t to avoid this. min/min and max/max nesting will always see this. I also introduced clamp()/clamp_t() in that patch for use in libata and drivers/media.

Quoted 18 lines
Quoted 9 lines
---
 drivers/char/rocket.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/rocket.c +0 -0
index 72f2892..2778d64 100644

drivers/char/rocket.c static void rp_do_transmit(struct r_port *info) · line 452

Quoted 6 lines
drivers/char/rocket.c +2 -1
@@ -448,7 +448,8 @@ static void rp_do_transmit(struct r_port *info)
 	while (1) {
 		if (tty->stopped || tty->hw_stopped)
 			break;
-		c = min(info->xmit_fifo_room, min(info->xmit_cnt, XMIT_BUF_SIZE - info->xmit_tail));
+		c = min(info->xmit_fifo_room, info->xmit_cnt);
+		c = min(c, XMIT_BUF_SIZE - info->xmit_tail);

Apart from things like that.

Quoted 2 lines

Probably this code is cleaner than the old version so let's do it, but it seems that we need a general fix.

min3()? No _good_ ideas I'm afraid.

Cheers,

Harvey

#3 lore raw
Quoted 4 lines · On Wed, 27 Feb 2008 15:38:07 -0800 Harvey Harrison <[email protected]>…
Quoted 2 lines

Probably this code is cleaner than the old version so let's do it, but it seems that we need a general fix.

min3()? No _good_ ideas I'm afraid.

Fix sparse, I'd say. Probably hard to do, but that warning really isn't useful.