From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07A65A04A2; Thu, 3 Mar 2022 16:18:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A4F24276B; Thu, 3 Mar 2022 16:18:41 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 5CC2340687 for ; Thu, 3 Mar 2022 16:18:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646320720; x=1677856720; h=message-id:date:to:cc:references:from:subject: in-reply-to:content-transfer-encoding:mime-version; bh=UhsqxwlxgtfecJG/vcocjFbU2ofYZM6bBQ50EFocm1g=; b=iKayOExFNcAEvoIFid0i3smLw6bCj8Ibfm+Bqp26nWx51Kj1vShMevI7 Yh4ZYErLojOtw+nNNwVMAvg+MumTsnvdvhLnpDqqr6ewjVjtvKz5b61Me Do8aWcpr5modLZ3v4oc1ysmGYJ412ZiR7UG5wlLL9gpOy5h+UCMkgRf5j yrcYZ1udwIKVvL+6yEnwWB0I2daicDKaRtZmnMmg97KZxBoLrpTOUrk/z Vv7vSTvIiVcV0Tdr1iIHebsdFOkkj3fvRqCVv/wPHjQ6AmK7Gn/XQTk7s pn6QzkKB59flNfkjBjmRWSKgAFjX4cHmsNM8gdQ13efW+Kdl7A8F7xpME A==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253892323" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253892323" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 07:18:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="609602644" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga004.fm.intel.com with ESMTP; 03 Mar 2022 07:18:39 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 07:18:39 -0800 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 07:18:38 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 3 Mar 2022 07:18:38 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 3 Mar 2022 07:18:38 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jsWK611UDMlDjOWizfFu0E+yleFDhQLsCuI00+z4rdPht4lYXIbJH+Y5rTrLxCcwa+GdPkScXRNyhBgT3hv+OOmq7ZdNHDm9EZngpvRWCGZkNiLx0L6drNuTUY+q91qKBCBpkKFkHFCsjERHv8tl+d6Y2oBc4RLkq7feeetYip0MHPmnOBqleHc5jJ4pxZ9oc6AwC2z4VL6c9EV/CYFsUnJ8uAotF+Ui9MdwgDKwp5f0HPzNIdzHHOr/ZHKehiSyJe7FUOjiKWOg+E0kq3fpak08RDBhURvql6HHrfAUPIIHqIAoju2kUZxE625Hy34tWO4/wcDivfRDvqUbKj7efQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9nMLzhdwZkAcVuVVTcYT8wdMDvKNGv900ix8kMnniWI=; b=E0g4zcVQdQSun5LAqQLtvuGnD9v3LW9Rj0FfXcezhSJZFF3QXrvp0BJCPXsaAbFY70qf1lSrdgMNkZxv7y9ZUIJ9yBbLO2X98c7/Vk2UhhnHOEHofzNWmFywbcn1oFRsg5TJVu7z+lVCEQw9Cu5INS75XJzaTvMX5FMyhdJietQZL6aN1ghR6qvxyyBrcjX0HJL5I/o6DsImLUa40XEvMN2pBKc5/KhO1N5CxSrLtldwxWRZGGSFmJNP3pKy3cFtxVg6Rb092BRprEc6RwVvR5yZHd12iQc7XdfcKrVswzTRUK23A9zKN1NRnU/OGuH9WMe8wnQ2IfyNPu1ffLrXOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by CH2PR11MB4293.namprd11.prod.outlook.com (2603:10b6:610:40::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 15:18:35 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd21:6fbe:8308:2ecf]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd21:6fbe:8308:2ecf%7]) with mapi id 15.20.5038.015; Thu, 3 Mar 2022 15:18:35 +0000 Message-ID: <8d26472c-13bb-8072-66cd-f9361d439aae@intel.com> Date: Thu, 3 Mar 2022 15:18:30 +0000 Content-Language: en-US To: Weiguo Li , dpdklab CC: , , , , , Ali Alnubani References: From: Ferruh Yigit Subject: Re: [PATCH] net/txgbe: fix a bit with boolean operator X-User: ferruhy In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0314.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:197::13) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ada5d6e7-4353-497d-d305-08d9fd2915e2 X-MS-TrafficTypeDiagnostic: CH2PR11MB4293:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wJwulr/pxwv9MektH5k/yP9RFECb1GnsBTkKAhwNGdSIgX5etg4nnlUNhwFKAV7EXiFvuCXK2ZXXK5BJywBs4/1P5TsNaPBJ8ncMolFuEWFufbH3ffGn0fA8vOLxlUsuZhdyt9DwOOyhr6r4BOOXmWj6ugX2YunyoV8PhmvpIpCPhUNCJTGWeujAY4eUdJ9bfijWsVvZxVse+pIsA/IRGRoG3sSkihpAVLriXNgh/cLUceTePfWHnCt66mNgAqTRilnEgLkBdLcc1tcW6qFYWwJwKUXmx1vR8Lt2MmTRwnEOY5pv2KRWt+jdWYb/2SNvIjqdYRECMoZcBa5kY9Z6VfdRP6D0JIqgab76BCLu7T08H1zv25EmE9h38ZfJadIv+gLLoymgLqs4JN2VVwK5vI2nI1qcEAby8BmeCKXJYn7JAh8UnY/M4Mip9jphpSiiTLcL6CH9hDeheb+5a6P9TtaE3M4axctip3O0Y8HcvMt6AOAh+EL4enTyplvxxCQDhBcgK9TuDnJaoMoQsujP6n+MREvhisDtMZZm7qegsucguLp6x/4YjJs8G4RQ0qhG5Te76frUvM0IXf62NSI+ECM07YuqYHBcUa0r2Veh6mZcbpe5rn+dTwVU0wflhDaZoOpsKppK8Eg0Y7oalgSnnG7q4NKdUJlOKjcOF6VvlVG8fncZDlV+kJCelk14zV0KM94vy2MaEuAgIa6T3TBWwzm06xS/HMvFTtrLCnu82rlKKeg1REp7eh4ey0RDKqpTu1ZGDVx1bwqzQ3Rca0LAj/SZs++UpRKjXVJK9mUYmUevB/jNcevYIiNZ/Z/fSm7E X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(8936002)(508600001)(86362001)(316002)(8676002)(4326008)(44832011)(82960400001)(38100700002)(6506007)(31686004)(53546011)(110136005)(2906002)(6486002)(36756003)(186003)(83380400001)(26005)(66476007)(2616005)(5660300002)(66556008)(66946007)(6512007)(6666004)(31696002)(48020200001)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NjVmSnRFejAwbFJTbXhoOTVrNFd3ZS9VQlFGOUtZdHNBaG9MV1VoUXNCTStD?= =?utf-8?B?NUFFa2l0RDlDV1MyTzdDUFU4MnRsOEpTMXk0cEFtR0U3ZjZmRjBSM3V3MU0v?= =?utf-8?B?dWhLYjA5OENxQXFIanh3TUh3aWJFT28yWWNBMGgxb0lkMlRLcnVBZlpSWktD?= =?utf-8?B?YzBRT1JuU2cydlh0UjlGSkdXOTBhNnRybEJVcnQvako3TnV3ZnVCUFltRGx4?= =?utf-8?B?K2dUQmNhcUxLUW1lWlVOcmJiWkFoMUovd296TEZaNVZ4TFBMenRvUWIxMDlz?= =?utf-8?B?UGtaWnJzOXdZSldzUy9SY3NRd3N0YlhCVit0TUJ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rV0NLRzB4SFF5Rk15MFgyNGhUYXh0cEhETGVJZGRraEM0a3krQ1V0SDZP?= =?utf-8?Q?95/wkpeEEUzraRbKWV7D+WY=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ada5d6e7-4353-497d-d305-08d9fd2915e2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 15:18:35.4808 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0+eguklJeprJnsxSBd+r8CJQv8izAbfB7SjM7kidO/b0CmMCbii6RoQW1msafqOa0yVZv0OUOneZnI1wrWUHfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR11MB4293 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 3/3/2022 1:31 PM, Weiguo Li wrote: > On March 2, 2022, 5:23 p.m Ferruh Yigit wrote: >> On 3/2/2022 8:02 AM, Jiawen Wu wrote: >>> On March 1, 2022 2:09 PM, Weiguo Li wrote: >>>> Since boolean value is in 0 and 1, it's strange to combines a boolean >>> value with >>>> a bit operator. >>>> >>>> Thus it's highly possible a typo error with "if (A & !B)", and more >>> probably to >>>> use "if (A & ~B)" instead. >>>> >>>> Fixes: c1d4e9d37abdc6 ("net/txgbe: add queue stats mapping") >>>> >>>> Signed-off-by: Weiguo Li >>>> --- >>>> drivers/net/txgbe/txgbe_ethdev.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/net/txgbe/txgbe_ethdev.c >>>> b/drivers/net/txgbe/txgbe_ethdev.c >>>> index 19d4444748..f0994f028d 100644 >>>> --- a/drivers/net/txgbe/txgbe_ethdev.c >>>> +++ b/drivers/net/txgbe/txgbe_ethdev.c >>>> @@ -376,7 +376,7 @@ txgbe_dev_queue_stats_mapping_set(struct >>>> rte_eth_dev *eth_dev, >>>> if (hw->mac.type != txgbe_mac_raptor) >>>> return -ENOSYS; >>>> >>>> - if (stat_idx & !QMAP_FIELD_RESERVED_BITS_MASK) >>>> + if (stat_idx & ~QMAP_FIELD_RESERVED_BITS_MASK) >>>> return -EIO; >>>> >>>> PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat >>>> index %d", >>>> -- >>>> 2.25.1 >>> >>> Thanks. >>> >>> Acked-by: Jiawen Wu >>> >> >> Hi Weiguo, >> >> Good catch, I wonder how did you detect this? >> >> If there is an automated way, maybe we can consider using >> it in our CI. >> > > Hi Ferruh, > > It's found by a coccinell script: > > @fix_bit_boolean @ expression E; constant C; @@ > ( > !E & !C > | > - !E & C > + !(E & C) > | > - E & !C > + E & ~C > ) > > the idea came from a demo script in coccinelle website: > (https://coccinelle.gitlabpages.inria.fr/website/rules/notand.html) > > @@ expression E; constant C; @@ > ( > !E & !C > | > - !E & C > + !(E & C) > ) > > The difference is in the last two lines and by which found the problem. > > I'd be happy if it would used in CI. > Maybe better to let Julia know, since she's the original author. > cc Julia > Thanks Weiguo. cc'ed lab people and Ali too. Aaron, lab, what do you think, can this be added into CI checks?