From patchwork Tue Apr 23 11:24:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 238891 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0E47C2C00DA for ; Tue, 23 Apr 2013 21:25:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754672Ab3DWLZW (ORCPT ); Tue, 23 Apr 2013 07:25:22 -0400 Received: from intranet.asianux.com ([58.214.24.6]:43318 "EHLO intranet.asianux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754424Ab3DWLZW (ORCPT ); Tue, 23 Apr 2013 07:25:22 -0400 Received: by intranet.asianux.com (Postfix, from userid 103) id 6AD7F1840242; Tue, 23 Apr 2013 19:25:21 +0800 (CST) X-Spam-Score: -100.8 X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on intranet.asianux.com X-Spam-Level: X-Spam-Status: No, score=-100.8 required=5.0 tests=AWL,BAYES_00, RATWARE_GECKO_BUILD, TW_XF, USER_IN_WHITELIST autolearn=no version=3.1.9 Received: from [10.1.0.143] (unknown [219.143.36.82]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by intranet.asianux.com (Postfix) with ESMTP id 0FB511840242; Tue, 23 Apr 2013 19:25:21 +0800 (CST) Message-ID: <51766F74.2090007@asianux.com> Date: Tue, 23 Apr 2013 19:24:36 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Sergei Shtylyov CC: alex.bluesman.smirnov@gmail.com, dbaryshkov@gmail.com, David Miller , linux-zigbee-devel@lists.sourceforge.net, netdev Subject: [PATCH v3] net: mac802154: comparision issue of type cast, finding by EXTRA_CFLAGS=-W References: <5174DB87.3010908@asianux.com> <51754485.6040708@cogentembedded.com> <5175DFBC.7040000@asianux.com> <5175F7F7.7000703@asianux.com> In-Reply-To: <5175F7F7.7000703@asianux.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 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 --- 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..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;