linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix MMC warnings
@ 2005-01-02  0:07 Pierre Ossman
  2005-01-02  8:44 ` Russell King
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Ossman @ 2005-01-02  0:07 UTC (permalink / raw)
  To: LKML, Russell King

[-- Attachment #1: Type: text/plain, Size: 58 bytes --]

Here's a patch that fixes the compiler warnings in mmc.c.

[-- Attachment #2: mmc-warning.patch --]
[-- Type: text/x-patch, Size: 714 bytes --]

Index: linux-wbsd/drivers/mmc/mmc.c
===================================================================
--- linux-wbsd/drivers/mmc/mmc.c	(revision 117)
+++ linux-wbsd/drivers/mmc/mmc.c	(working copy)
@@ -428,14 +428,14 @@
 
 #define UNSTUFF_BITS(resp,start,size)					\
 	({								\
-		const u32 __mask = (1 << (size)) - 1;			\
+		const u32 __mask = ((size >= 32)?0:(1 << (size))) - 1;	\
 		const int __off = 3 - ((start) / 32);			\
 		const int __shft = (start) & 31;			\
 		u32 __res;						\
 									\
 		__res = resp[__off] >> __shft;				\
 		if ((size) + __shft >= 32)				\
-			__res |= resp[__off-1] << (32 - __shft);	\
+			__res |= resp[__off-1] << ((32 - __shft) % 32);	\
 		__res & __mask;						\
 	})
 

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

* Re: [PATCH] Fix MMC warnings
  2005-01-02  0:07 [PATCH] Fix MMC warnings Pierre Ossman
@ 2005-01-02  8:44 ` Russell King
  2005-01-02 11:55   ` Russell King
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King @ 2005-01-02  8:44 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: LKML

On Sun, Jan 02, 2005 at 01:07:31AM +0100, Pierre Ossman wrote:
> Here's a patch that fixes the compiler warnings in mmc.c.

I'd rather the compiler was fixed so that it does proper analysis of
the code, rather than blatently issuing warnings for code which is
unreachable.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

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

* Re: [PATCH] Fix MMC warnings
  2005-01-02  8:44 ` Russell King
@ 2005-01-02 11:55   ` Russell King
  0 siblings, 0 replies; 3+ messages in thread
From: Russell King @ 2005-01-02 11:55 UTC (permalink / raw)
  To: Pierre Ossman, LKML

On Sun, Jan 02, 2005 at 08:44:09AM +0000, Russell King wrote:
> On Sun, Jan 02, 2005 at 01:07:31AM +0100, Pierre Ossman wrote:
> > Here's a patch that fixes the compiler warnings in mmc.c.
> 
> I'd rather the compiler was fixed so that it does proper analysis of
> the code, rather than blatently issuing warnings for code which is
> unreachable.

Actually, you're quite correct about the first instance - 'mask' may
be generated from 1 << 32 - 1, which is definitely reachable, and gcc
will warn about.  There's also another bug - an out by one on whether
to use the second word to construct the value.

However, the other 5 warnings are due to (corrected version):

	if (16 + 0 > 32)
		__res |= resp[__off-1] << (32 - 0);

Obviously, this code is not reachable since the if condition is false.
Therefore, gcc's whinging about the shift being >= 32 is wrong.

That said, the fix doesn't change gcc's code generation, so I think I'll
apply the changes.  Thanks.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

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

end of thread, other threads:[~2005-01-02 11:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-02  0:07 [PATCH] Fix MMC warnings Pierre Ossman
2005-01-02  8:44 ` Russell King
2005-01-02 11:55   ` Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).