Patchwork [v3] net: mac802154: comparision issue of type cast, finding by EXTRA_CFLAGS=-W

login
register
mail settings
Submitter Chen Gang
Date April 23, 2013, 11:24 a.m.
Message ID <51766F74.2090007@asianux.com>
Download mbox | patch
Permalink /patch/238891/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Chen Gang - April 23, 2013, 11:24 a.m.
Need change ~(u8)0 to 0xff, or in mac802154_wpan_xmit(), "u8 chan"
will never == MAC802154_CHAN_NONE.

The related warning:
  net/mac802154/wpan.c:325:2: warning: comparison is always false
  due to limited range of data type [-Wtype-limits]

The related unit test:
  cc -Wall -O2 -o test test.c
  ./test
  will output 'different'

  (after use '0xff' instead of '~(u8)0', it will output 'equal')

-----------------------test code begin--------------------------------

#include <stdio.h>

typedef unsigned char u8;

int main()
{
	u8 uc = 0xff;

	if (uc == ~(u8)0)
		printf("\nequal\n");
	else
		printf("\ndifferent\n");

	return 0;
}

-----------------------test code end----------------------------------


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 net/mac802154/mac802154.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
David Miller - April 25, 2013, 8:10 a.m.
From: Chen Gang <gang.chen@asianux.com>
Date: Tue, 23 Apr 2013 19:24:36 +0800

> 
> Need change ~(u8)0 to 0xff, or in mac802154_wpan_xmit(), "u8 chan"
> will never == MAC802154_CHAN_NONE.
> 
> The related warning:
>   net/mac802154/wpan.c:325:2: warning: comparison is always false
>   due to limited range of data type [-Wtype-limits]
> 
> The related unit test:
>   cc -Wall -O2 -o test test.c
>   ./test
>   will output 'different'
> 
>   (after use '0xff' instead of '~(u8)0', it will output 'equal')
 ...
> Signed-off-by: Chen Gang <gang.chen@asianux.com>

This change belong in the 'net' tree, but your patch won't apply
cleanly there as this part of the header file looks slightly
different there.

Please respin your patch against 'net' and resubmit, thank you.
--
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
Chen Gang - April 25, 2013, 8:43 a.m.
On 2013年04月25日 16:10, David Miller wrote:
> From: Chen Gang <gang.chen@asianux.com>
> Date: Tue, 23 Apr 2013 19:24:36 +0800
> 
>> > 
>> > Need change ~(u8)0 to 0xff, or in mac802154_wpan_xmit(), "u8 chan"
>> > will never == MAC802154_CHAN_NONE.
>> > 
>> > The related warning:
>> >   net/mac802154/wpan.c:325:2: warning: comparison is always false
>> >   due to limited range of data type [-Wtype-limits]
>> > 
>> > The related unit test:
>> >   cc -Wall -O2 -o test test.c
>> >   ./test
>> >   will output 'different'
>> > 
>> >   (after use '0xff' instead of '~(u8)0', it will output 'equal')
>  ...
>> > Signed-off-by: Chen Gang <gang.chen@asianux.com>
> This change belong in the 'net' tree, but your patch won't apply
> cleanly there as this part of the header file looks slightly
> different there.
> 
> Please respin your patch against 'net' and resubmit, thank you.
> 

Excuse me, my English is not quite well, I guess your meaning is: send
patch v4, and change the subject to "[PATCH v4] mac802154: comparision
issue of type cast, finding by EXTRA_CFLAGS=-W".

Is it correct ?

(the change is for net/mac802154/mac802154.h, and exist in v3.9-rc8)

Thanks.
David Miller - April 25, 2013, 9:01 a.m.
From: Chen Gang <gang.chen@asianux.com>
Date: Thu, 25 Apr 2013 16:43:14 +0800

> (the change is for net/mac802154/mac802154.h, and exist in v3.9-rc8)

It exist, but your patch doesn't apply cleanly there, it only applies
cleanly to the -next tree, because other changes have happend to that
file in -next.
--
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
Christophe Aeschlimann - April 25, 2013, 9:02 a.m.
Hi Chen,

Le 25.04.2013 10:43, Chen Gang a écrit :
> On 2013年04月25日 16:10, David Miller wrote:
>>
>> Please respin your patch against 'net' and resubmit, thank you.
>>
> 
> Excuse me, my English is not quite well, I guess your meaning is: send
> patch v4, and change the subject to "[PATCH v4] mac802154: comparision
> issue of type cast, finding by EXTRA_CFLAGS=-W".
> 
> Is it correct ?
> 
> (the change is for net/mac802154/mac802154.h, and exist in v3.9-rc8)
> 
> Thanks.

He means you should clone :

git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git

And apply your change to that tree and re-submit. (mac802154.h is
slightly different in that tree).

Best regards,
Chen Gang - April 25, 2013, 9:06 a.m.
On 2013年04月25日 17:02, Christophe Aeschlimann wrote:
> Hi Chen,
> 
> Le 25.04.2013 10:43, Chen Gang a écrit :
>> > On 2013年04月25日 16:10, David Miller wrote:
>>> >>
>>> >> Please respin your patch against 'net' and resubmit, thank you.
>>> >>
>> > 
>> > Excuse me, my English is not quite well, I guess your meaning is: send
>> > patch v4, and change the subject to "[PATCH v4] mac802154: comparision
>> > issue of type cast, finding by EXTRA_CFLAGS=-W".
>> > 
>> > Is it correct ?
>> > 
>> > (the change is for net/mac802154/mac802154.h, and exist in v3.9-rc8)
>> > 
>> > Thanks.
> He means you should clone :
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
> 
> And apply your change to that tree and re-submit. (mac802154.h is
> slightly different in that tree).
> 

OK, thank you very much, I will follow.
Chen Gang - April 25, 2013, 9:09 a.m.
On 2013年04月25日 17:01, David Miller wrote:
> From: Chen Gang <gang.chen@asianux.com>
> Date: Thu, 25 Apr 2013 16:43:14 +0800
> 
>> > (the change is for net/mac802154/mac802154.h, and exist in v3.9-rc8)
> It exist, but your patch doesn't apply cleanly there, it only applies
> cleanly to the -next tree, because other changes have happend to that
> file in -next.
> 
> 

OK, thanks. I will send patch v4 (still use the current subject and
comments)

Patch

diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 5c9e021..d48422e 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -88,7 +88,7 @@  struct mac802154_sub_if_data {
 
 #define mac802154_to_priv(_hw)	container_of(_hw, struct mac802154_priv, hw)
 
-#define MAC802154_CHAN_NONE		(~(u8)0) /* No channel is assigned */
+#define MAC802154_CHAN_NONE		0xff /* No channel is assigned */
 
 extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
 extern struct ieee802154_mlme_ops mac802154_mlme_wpan;