diff mbox

[31/43] drivers/net/tokenring: fix sparse warning: cast truncates bits from const value

Message ID 20090214214452.24377.31953.stgit@vmbox.hanneseder.net
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Hannes Eder Feb. 14, 2009, 9:46 p.m. UTC
Impact: Use '__u16' instead of '__u8', this possibly fixes a bug.

Fix this sparse warnings:
  drivers/net/tokenring/smctr.c:4410:52: warning: cast truncates bits from constant value (100 becomes 0)
  drivers/net/tokenring/smctr.c:4415:52: warning: cast truncates bits from constant value (400 becomes 0)
  drivers/net/tokenring/smctr.c:4420:52: warning: cast truncates bits from constant value (800 becomes 0)
  drivers/net/tokenring/smctr.c:4425:52: warning: cast truncates bits from constant value (1000 becomes 0)
  drivers/net/tokenring/smctr.c:4430:52: warning: cast truncates bits from constant value (2000 becomes 0)
  drivers/net/tokenring/smctr.c:4435:52: warning: cast truncates bits from constant value (4000 becomes 0)
  drivers/net/tokenring/smctr.c:4440:52: warning: cast truncates bits from constant value (8000 becomes 0)

Signed-off-by: Hannes Eder <hannes@hanneseder.net>
---

Should the members be rearranged to avoid un-aligned access?

 drivers/net/tokenring/smctr.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


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

Comments

Al Viro Feb. 14, 2009, 11:24 p.m. UTC | #1
On Sat, Feb 14, 2009 at 10:46:24PM +0100, Hannes Eder wrote:
> Impact: Use '__u16' instead of '__u8', this possibly fixes a bug.
> 
> Fix this sparse warnings:
>   drivers/net/tokenring/smctr.c:4410:52: warning: cast truncates bits from constant value (100 becomes 0)
>   drivers/net/tokenring/smctr.c:4415:52: warning: cast truncates bits from constant value (400 becomes 0)
>   drivers/net/tokenring/smctr.c:4420:52: warning: cast truncates bits from constant value (800 becomes 0)
>   drivers/net/tokenring/smctr.c:4425:52: warning: cast truncates bits from constant value (1000 becomes 0)
>   drivers/net/tokenring/smctr.c:4430:52: warning: cast truncates bits from constant value (2000 becomes 0)
>   drivers/net/tokenring/smctr.c:4435:52: warning: cast truncates bits from constant value (4000 becomes 0)
>   drivers/net/tokenring/smctr.c:4440:52: warning: cast truncates bits from constant value (8000 becomes 0)

Um, no.  Here's a better question: does *anything* use ->current_ring_status
at all?  Answer: no.  Next question: did anything use it in the past?
git log -p drivers/net/tokenging/smctr.c in historical trees shows that
it had always been defined that way and that it had never been used at
all.

So how about removing the damn field completely?  Or asking the driver's
author what the hell had it been about?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Eder Feb. 15, 2009, 11:47 a.m. UTC | #2
On Sun, Feb 15, 2009 at 12:24 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Sat, Feb 14, 2009 at 10:46:24PM +0100, Hannes Eder wrote:
>> Impact: Use '__u16' instead of '__u8', this possibly fixes a bug.
>>
>> Fix this sparse warnings:
>>   drivers/net/tokenring/smctr.c:4410:52: warning: cast truncates bits from constant value (100 becomes 0)
>>   drivers/net/tokenring/smctr.c:4415:52: warning: cast truncates bits from constant value (400 becomes 0)
>>   drivers/net/tokenring/smctr.c:4420:52: warning: cast truncates bits from constant value (800 becomes 0)
>>   drivers/net/tokenring/smctr.c:4425:52: warning: cast truncates bits from constant value (1000 becomes 0)
>>   drivers/net/tokenring/smctr.c:4430:52: warning: cast truncates bits from constant value (2000 becomes 0)
>>   drivers/net/tokenring/smctr.c:4435:52: warning: cast truncates bits from constant value (4000 becomes 0)
>>   drivers/net/tokenring/smctr.c:4440:52: warning: cast truncates bits from constant value (8000 becomes 0)
>
> Um, no.  Here's a better question: does *anything* use ->current_ring_status
> at all?  Answer: no.  Next question: did anything use it in the past?
> git log -p drivers/net/tokenging/smctr.c in historical trees shows that
> it had always been defined that way and that it had never been used at
> all.
>
> So how about removing the damn field completely?  Or asking the driver's
> author what the hell had it been about?
>

I vote for removing the field, I prepare a patch for this.

Comments?

-Hannes
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/tokenring/smctr.h b/drivers/net/tokenring/smctr.h
index 52df7dd..d98bc5b 100644
--- a/drivers/net/tokenring/smctr.h
+++ b/drivers/net/tokenring/smctr.h
@@ -977,7 +977,7 @@  typedef struct net_local {
 	__u8		monitor_state_ready;
 	__u16		ring_status;
 	__u8		ring_status_flags;
-	__u8		current_ring_status;
+	__u16		current_ring_status;
 	__u8		state;
 
 	__u8		join_state;