Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp923256rdh; Fri, 24 Nov 2023 00:53:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjpRh2WFqjlrw0zvZPvjQfH3b89MWQ4s4J4Codr3WbWqk2wbJZMTmZg4S0DYhYGwbgYt3Y X-Received: by 2002:a05:6a20:c18b:b0:18b:251d:d6fb with SMTP id bg11-20020a056a20c18b00b0018b251dd6fbmr2647006pzb.1.1700816019868; Fri, 24 Nov 2023 00:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700816019; cv=none; d=google.com; s=arc-20160816; b=JqIsPTuYJrEd09/WsYI9fW26fFQY8oQ8SaQusEZ3rN9qUPt/CrbUJQJRwWrg4e+vew c1ti/pgpLwfVbr1q1W812p6zTdT0zqjtVw2pPupTgUys0y+kKe1g46Dy/7+fYWk61FMY p1ocwCqhYiEcYKmXQB5ePC8/CqfxOHSUUBc09WbaznGzNzEnl6g248pBZadlZCJjUxvv cAXyrfnYjq7ZE0hZDSJ4db1g7xSQFZ6Eo50LuUnl2mHpKMaOgfuwKBS/Km1Zotzwuh3I wdCcYipqkTey8v/++56ykt/0DJYxn7DGLyN/lo5FRSO5he/E7fIflss8gTSowaXnOfnm yJ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=Cvc7PkszpMSlmsrlSABGzt8uO7csHqWASzF2sJgJ/Xo=; fh=B3A4gBSNqIYhVj1G/nBhhEolDgcdKQXyRkzRGa+rbiY=; b=hj0e/DxSQ3cmPX85PgydEVjAYLTUWL69uN5l8SC5suXdw3PLgHpj1JC0K7GhjMvRB3 jHuoBsst+UjUJy2T5mfcqdDWLxTByAuCktjfXYL8bmutKsKCaDHVjnl4NOAq2Q7J7rS1 WjtQis1patkzKAF3P4ZEiQRZ895U53DsPjzyESIVwlT0SY7Gje1dlEJdjTzXhvJ5PsAV q9JvPYI2OqNyLzL7Yx7zseIHRcLmedhpdtaE3WVcoqtVgR2jfS+KJusMraoDK1vA9nUZ yU4LLza8XeIn+OL13k+/bzoZ/YtihvsOM9oaElt62SGjJ7lNIq8stpk66nuMVsqlRcg+ 4MOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y15-20020a056a00190f00b006cbe3c123a6si3066127pfi.9.2023.11.24.00.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 00:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B4D02B20CC4 for ; Fri, 24 Nov 2023 08:53:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26E1465C; Fri, 24 Nov 2023 08:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B630D53; Fri, 24 Nov 2023 00:53:26 -0800 (PST) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 3AO8pJvQ53617164, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 3AO8pJvQ53617164 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Nov 2023 16:51:21 +0800 Received: from RTEXDAG01.realtek.com.tw (172.21.6.100) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 24 Nov 2023 16:51:20 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXDAG01.realtek.com.tw (172.21.6.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 24 Nov 2023 16:51:15 +0800 Received: from RTEXMBS04.realtek.com.tw ([fe80::40c2:6c24:2df4:e6c7]) by RTEXMBS04.realtek.com.tw ([fe80::40c2:6c24:2df4:e6c7%5]) with mapi id 15.01.2375.007; Fri, 24 Nov 2023 16:51:15 +0800 From: Ping-Ke Shih To: Su Hui , "dan.carpenter@linaro.org" , "kvalo@kernel.org" , "nathan@kernel.org" , "ndesaulniers@google.com" , "trix@redhat.com" CC: "lizetao1@huawei.com" , "linville@tuxdriver.com" , "Larry.Finger@lwfinger.net" , "linux-wireless@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "llvm@lists.linux.dev" , "kernel-janitors@vger.kernel.org" Subject: RE: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior Thread-Topic: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior Thread-Index: AQHaHnqh3ek0X9cmrkSIvDKQ0v3B9rCJKRKA Date: Fri, 24 Nov 2023 08:51:15 +0000 Message-ID: <167fbc7a77db447d90f696666f6f0a9b@realtek.com> References: <20231124020352.1660621-1-suhui@nfschina.com> <20231124020352.1660621-2-suhui@nfschina.com> In-Reply-To: <20231124020352.1660621-2-suhui@nfschina.com> Accept-Language: en-US, zh-TW Content-Language: zh-TW x-kse-serverinfo: RTEXDAG01.realtek.com.tw, 9 x-kse-antispam-interceptor-info: fallback x-kse-antivirus-interceptor-info: fallback Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KSE-AntiSpam-Interceptor-Info: fallback > -----Original Message----- > From: Su Hui > Sent: Friday, November 24, 2023 10:04 AM > To: dan.carpenter@linaro.org; Ping-Ke Shih ; kvalo@ke= rnel.org; nathan@kernel.org; > ndesaulniers@google.com; trix@redhat.com > Cc: Su Hui ; lizetao1@huawei.com; linville@tuxdriver.= com; Larry.Finger@lwfinger.net; > linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; llvm@lists.= linux.dev; > kernel-janitors@vger.kernel.org > Subject: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined b= itwise shift behavior >=20 [...] >=20 > diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c > b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c > index 6df270e29e66..52ab1b0761c0 100644 > --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c > +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c > @@ -31,7 +31,12 @@ static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitm= ask) > { > u32 i =3D ffs(bitmask); >=20 > - return i ? i - 1 : 32; > + if (!i) { > + WARN_ON_ONCE(1); > + return 0; > + } > + > + return i - 1; > } Personally, I prefer to use __ffs(), because in normal case no need additio= nal '-1', and abnormal cases should not happen.=20