netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Net: mac802154: comparing issue by type cast, finding by EXTRA_CFLAGS=-W
@ 2013-04-22  6:41 Chen Gang
  2013-04-22 14:09 ` Sergei Shtylyov
  0 siblings, 1 reply; 18+ messages in thread
From: Chen Gang @ 2013-04-22  6:41 UTC (permalink / raw)
  To: alex.bluesman.smirnov, dbaryshkov
  Cc: David Miller, linux-zigbee-devel, netdev


  need change ~(u8)0 to 0xff,
  or in mac802154_wpan_xmit(), "u8 chan" will never == MAC802154_CHAN_NONE

  find it by "make EXTRA_CFLAGS=-W"
    net/mac802154/wpan.c:325:2: warning: comparison is always false
    due to limited range of data type [-Wtype-limits]

  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(-)

diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 5c9e021..c59309f 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;
-- 
1.7.7.6

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

end of thread, other threads:[~2013-05-02  1:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-22  6:41 [PATCH] Net: mac802154: comparing issue by type cast, finding by EXTRA_CFLAGS=-W Chen Gang
2013-04-22 14:09 ` Sergei Shtylyov
2013-04-23  1:11   ` Chen Gang
2013-04-23  2:54     ` [PATCH v2] Net: mac802154: comparision issue of " Chen Gang
2013-04-23 11:22       ` Chen Gang
2013-04-23 11:24       ` [PATCH v3] net: " Chen Gang
2013-04-25  8:10         ` David Miller
2013-04-25  8:43           ` Chen Gang
2013-04-25  9:01             ` David Miller
2013-04-25  9:09               ` Chen Gang
     [not found]             ` <5178ECA2.6020402-bOixZGp5f+dBDgjK7y7TUQ@public.gmane.org>
2013-04-25  9:02               ` Christophe Aeschlimann
2013-04-25  9:06                 ` Chen Gang
2013-04-25  9:40                 ` [PATCH v4] " Chen Gang
2013-04-25  9:59                   ` Daniel Borkmann
2013-04-25 10:44                     ` Chen Gang
2013-04-25 10:49                     ` [PATCH v5] " Chen Gang
2013-04-29 16:29                       ` David Miller
2013-05-02  1:11                         ` Chen Gang

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).