All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Knutsson <ricknu-0@student.ltu.se>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-pcmcia@lists.infradead.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] pcmcia/3c574_cs: Fix dubious bitfield warning
Date: Wed, 12 Dec 2007 01:40:56 +0000	[thread overview]
Message-ID: <475F3C28.7010409@student.ltu.se> (raw)
In-Reply-To: <20071211131936.3379f2af@the-village.bc.nu>

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

Alan Cox wrote:
> On Tue, 11 Dec 2007 05:32:38 +0100 (MET)
> Richard Knutsson <ricknu-0@student.ltu.se> wrote:
>
>   
>> Fixing:
>>   CHECK   drivers/net/pcmcia/3c574_cs.c
>> drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without explicit `signed' or `unsigned'
>> drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without explicit `signed' or `unsigned'
>>
>> Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
>> ---
>> Is there a reason for not doing it this way?
>>     
>
> How is the endianness handled here (I suspect its always been broken)
>   
Guess so, but it should not handle the endians differently with such a 
change, does it?
>   
>> diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
>> index ad134a6..97b6daa 100644
>> --- a/drivers/net/pcmcia/3c574_cs.c
>> +++ b/drivers/net/pcmcia/3c574_cs.c
>> @@ -190,10 +190,10 @@ enum Window3 {			/* Window 3: MAC/config bits. */
>>  union wn3_config {
>>  	int i;
>>  	struct w3_config_fields {
>> -		unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
>> -		int pad8:8;
>> -		unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
>> -		int pad24:7;
>> +		u8 ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
>> +		u8 pad8;
>> +		u8 ram_split:2, pad18:2, xcvr:3, pad21:1;
>> +		u8 autoselect:1, pad24:7;
>>     
>
> Just changing the int pad to unsigned int pad would be safer in terms of
> not causing changes. Simply delcaring a 32bit field and bit masks to
> and/or into it is probably a lot saner in the general case.
>   
Thought about it before and with the endian-issue it seem like a better 
solution.
So, something like this?


[-- Attachment #2: drivers_net_pcmcia_3c574_cs.c-dubious-bitfield.patch --]
[-- Type: text/x-patch, Size: 1062 bytes --]

Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
---
Moved 'autoselect' to the last line to make every line 8 bits.
Is there a reason for not doing it this way?


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..e549427 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {			/* Window 3: MAC/config bits. */
 union wn3_config {
 	int i;
 	struct w3_config_fields {
-		unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-		int pad8:8;
-		unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
-		int pad24:7;
+		u32 ram_size:3, ram_width:1, ram_speed:2, rom_size:2,
+		    pad8:8,
+		    ram_split:2, pad18:2, xcvr:3, pad21:1,
+		    autoselect:1, pad24:7;
 	} u;
 };
 

WARNING: multiple messages have this Message-ID (diff)
From: Richard Knutsson <ricknu-0@student.ltu.se>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-pcmcia@lists.infradead.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] pcmcia/3c574_cs: Fix dubious bitfield warning
Date: Wed, 12 Dec 2007 02:40:56 +0100	[thread overview]
Message-ID: <475F3C28.7010409@student.ltu.se> (raw)
In-Reply-To: <20071211131936.3379f2af@the-village.bc.nu>

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

Alan Cox wrote:
> On Tue, 11 Dec 2007 05:32:38 +0100 (MET)
> Richard Knutsson <ricknu-0@student.ltu.se> wrote:
>
>   
>> Fixing:
>>   CHECK   drivers/net/pcmcia/3c574_cs.c
>> drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without explicit `signed' or `unsigned'
>> drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without explicit `signed' or `unsigned'
>>
>> Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
>> ---
>> Is there a reason for not doing it this way?
>>     
>
> How is the endianness handled here (I suspect its always been broken)
>   
Guess so, but it should not handle the endians differently with such a 
change, does it?
>   
>> diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
>> index ad134a6..97b6daa 100644
>> --- a/drivers/net/pcmcia/3c574_cs.c
>> +++ b/drivers/net/pcmcia/3c574_cs.c
>> @@ -190,10 +190,10 @@ enum Window3 {			/* Window 3: MAC/config bits. */
>>  union wn3_config {
>>  	int i;
>>  	struct w3_config_fields {
>> -		unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
>> -		int pad8:8;
>> -		unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
>> -		int pad24:7;
>> +		u8 ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
>> +		u8 pad8;
>> +		u8 ram_split:2, pad18:2, xcvr:3, pad21:1;
>> +		u8 autoselect:1, pad24:7;
>>     
>
> Just changing the int pad to unsigned int pad would be safer in terms of
> not causing changes. Simply delcaring a 32bit field and bit masks to
> and/or into it is probably a lot saner in the general case.
>   
Thought about it before and with the endian-issue it seem like a better 
solution.
So, something like this?


[-- Attachment #2: drivers_net_pcmcia_3c574_cs.c-dubious-bitfield.patch --]
[-- Type: text/x-patch, Size: 1062 bytes --]

Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
---
Moved 'autoselect' to the last line to make every line 8 bits.
Is there a reason for not doing it this way?


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..e549427 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {			/* Window 3: MAC/config bits. */
 union wn3_config {
 	int i;
 	struct w3_config_fields {
-		unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-		int pad8:8;
-		unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
-		int pad24:7;
+		u32 ram_size:3, ram_width:1, ram_speed:2, rom_size:2,
+		    pad8:8,
+		    ram_split:2, pad18:2, xcvr:3, pad21:1,
+		    autoselect:1, pad24:7;
 	} u;
 };
 

  reply	other threads:[~2007-12-12  1:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-11  4:32 [PATCH 1/6] pcmcia/3c574_cs: Fix dubious bitfield warning Richard Knutsson
2007-12-11  4:32 ` Richard Knutsson
2007-12-11  4:32 ` [PATCH 2/6] pcmcia/3c574_cs: Fix 'shadow variable' warning Richard Knutsson
2007-12-11  4:32   ` Richard Knutsson
2007-12-11 13:22   ` Alan Cox
2007-12-11 13:22     ` Alan Cox
2007-12-11  4:32 ` [PATCH 3/6] pcmcia/axnet_cs: Make functions static Richard Knutsson
2007-12-11  4:32   ` Richard Knutsson
2007-12-11  4:32 ` [PATCH 4/6] pcmcia/axnet_cs: Make use of 'max()' instead of handcrafted one Richard Knutsson
2007-12-11  4:32   ` Richard Knutsson
2007-12-11  4:32 ` [PATCH 5/6] pcmcia/fmvj18x_cs: Fix 'shadow variable' warning Richard Knutsson
2007-12-11  4:32   ` Richard Knutsson
2007-12-11  4:33 ` [PATCH 6/6] pcmcia/pcnet_cs: " Richard Knutsson
2007-12-11  4:33   ` Richard Knutsson
2007-12-11 13:19 ` [PATCH 1/6] pcmcia/3c574_cs: Fix dubious bitfield warning Alan Cox
2007-12-11 13:19   ` Alan Cox
2007-12-12  1:40   ` Richard Knutsson [this message]
2007-12-12  1:40     ` Richard Knutsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=475F3C28.7010409@student.ltu.se \
    --to=ricknu-0@student.ltu.se \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.