Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 114F0C636D4 for ; Wed, 15 Feb 2023 10:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234249AbjBOK7G convert rfc822-to-8bit (ORCPT ); Wed, 15 Feb 2023 05:59:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234186AbjBOK7B (ORCPT ); Wed, 15 Feb 2023 05:59:01 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB97038014 for ; Wed, 15 Feb 2023 02:58:50 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-247-_tHePesBO6agGi7ci4R_tw-1; Wed, 15 Feb 2023 10:58:47 +0000 X-MC-Unique: _tHePesBO6agGi7ci4R_tw-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Wed, 15 Feb 2023 10:58:46 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.045; Wed, 15 Feb 2023 10:58:46 +0000 From: David Laight To: 'Arnd Bergmann' , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Martyna Szapar-Mudlaw" CC: Arnd Bergmann , Marcin Szycik , Amritha Nambiar , Michal Swiatkowski , Wojciech Drewek , "intel-wired-lan@lists.osuosl.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] ethernet: ice: avoid gcc-9 integer overflow warning Thread-Topic: [PATCH] ethernet: ice: avoid gcc-9 integer overflow warning Thread-Index: AQHZQHcTjgyLfxurwEKHiQFStKAE+67P1n2g Date: Wed, 15 Feb 2023 10:58:46 +0000 Message-ID: References: <20230214132002.1498163-1-arnd@kernel.org> In-Reply-To: <20230214132002.1498163-1-arnd@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann > Sent: 14 February 2023 13:20 > > From: Arnd Bergmann > > With older compilers like gcc-9, the calculation of the vlan > priority field causes a warning from the byteswap: > ... > > Fixes: 34800178b302 ("ice: Add support for VLAN priority filters in switchdev") > Signed-off-by: Arnd Bergmann > --- > drivers/net/ethernet/intel/ice/ice_tc_lib.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_tc_lib.c b/drivers/net/ethernet/intel/ice/ice_tc_lib.c > index 6b48cbc049c6..e9932446185c 100644 > --- a/drivers/net/ethernet/intel/ice/ice_tc_lib.c > +++ b/drivers/net/ethernet/intel/ice/ice_tc_lib.c > @@ -1453,10 +1453,9 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi, > } > > if (match.mask->vlan_priority) { > + u16 prio = (match.key->vlan_priority << VLAN_PRIO_SHIFT) & VLAN_PRIO_MASK; > fltr->flags |= ICE_TC_FLWR_FIELD_VLAN_PRIO; > - headers->vlan_hdr.vlan_prio = > - cpu_to_be16((match.key->vlan_priority << > - VLAN_PRIO_SHIFT) & VLAN_PRIO_MASK); > + headers->vlan_hdr.vlan_prio = cpu_to_be16(prio); > } Is there something that will do: unsigned int pri = match.key->vlan_priority & (VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT); headers->vlan_hdr.vlan_prio = pri << (VLAN_PRIO_SHIFT ^ (le ? 8 : 0)); David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)