char: fix sparse shadowed variable warnings in cyclades.c
PATCH 1/1 char: fix sparse shadowed variable warnings in cyclades.c
Nested min() macros.drivers/char/cyclades.c:2750:7: warning: symbol '_x' shadows an earlier one drivers/char/cyclades.c:2750:7: originally declared here drivers/char/cyclades.c:2750:7: warning: symbol '_x' shadows an earlier one drivers/char/cyclades.c:2750:7: originally declared here drivers/char/cyclades.c:2750:7: warning: symbol '_y' shadows an earlier one drivers/char/cyclades.c:2750:7: originally declared here
--- drivers/char/cyclades.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/cyclades.c +2 -2
@@ -2747,8 +2747,8 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)spin_lock_irqsave (&info->card->card_lock, flags);while (1 ) { - c =min (count,min ((int )(SERIAL_XMIT_SIZE - info->xmit_cnt -1 ), - (int )(SERIAL_XMIT_SIZE - info->xmit_head))); + c =min (count, (int )(SERIAL_XMIT_SIZE - info->xmit_cnt -1 )); + c =min (c, (int )(SERIAL_XMIT_SIZE - info->xmit_head));if (c <=0 )break ;
Signature · 1 line
1.5.4.2.200.g99e75
Quoted 18 lines · On Fri, 22 Feb 2008 10:14:15 -0800 Harvey Harrison <[email protected]>…
Nested
min()macros.drivers/char/cyclades.c:2750:7: warning: symbol '_x' shadows an earlier onedrivers/char/cyclades.c:2750:7: originally declared heredrivers/char/cyclades.c:2750:7: warning: symbol '_x' shadows an earlier onedrivers/char/cyclades.c:2750:7: originally declared heredrivers/char/cyclades.c:2750:7: warning: symbol '_y' shadows an earlier onedrivers/char/cyclades.c:2750:7: originally declared hereSigned-off-by Harvey Harrison <[email protected]>--- drivers/char/cyclades.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/char/cyclades.c +0
-0
drivers/char/cyclades.c static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) · line 2754
Quoted 10 lines
drivers/char/cyclades.c +2
-2@@ -2747,8 +2747,8 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)spin_lock_irqsave (&info->card->card_lock, flags);while (1 ) { - c =min (count,min ((int )(SERIAL_XMIT_SIZE - info->xmit_cnt -1 ), - (int )(SERIAL_XMIT_SIZE - info->xmit_head))); + c =min (count, (int )(SERIAL_XMIT_SIZE - info->xmit_cnt -1 )); + c =min (c, (int )(SERIAL_XMIT_SIZE - info->xmit_head));if (c <=0 )break ;
Unrelated to your change, but...
We prefer min_t over casts like this (not sure why, but let's be consistent)
The reason for this cast is that all this code is using `int' for the transfer count (arguably wrong - should use size_t, but that propagates all the way to tty_operations.write) but cyclades has
#define SERIAL_XMIT_SIZE (min(PAGE_SIZE, 4096))
which is unsigned on most architectures.
A possibly-sane fix for all of this is to use min_t in the above then nuke the casts.
Quoted 11 lines · Andrew Morton
On Fri, 22 Feb 2008 10:14:15 -0800
Harvey Harrison <[email protected]> wrote:Unrelated to your change, but...
We prefer
min_tover casts like this (not sure why, but let's be consistent)The reason for this cast is that all this code is using `int' for the transfer count (arguably wrong - should use
size_t, but that propagates all the way to tty_operations.write) but cyclades has
Quoted 7 lines
#define
SERIAL_XMIT_SIZE(min(PAGE_SIZE, 4096))which is unsigned on most architectures.
A possibly-sane fix for all of this is to use
min_tin the above then nuke the casts.
I'll trace this through and get you a patch.
Harvey