Message ID | 20221028063711.GA35659@rdm |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp658146wru; Thu, 27 Oct 2022 23:41:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68S9MmkBeIShveU8IslLhjFFHmsJ/FWa0hfRQYEQj3QxkmdzkAxyWuPITQD8ShhWDer8Ug X-Received: by 2002:a63:8449:0:b0:46e:ecba:c46d with SMTP id k70-20020a638449000000b0046eecbac46dmr26860947pgd.310.1666939300127; Thu, 27 Oct 2022 23:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666939300; cv=none; d=google.com; s=arc-20160816; b=V7FSKaDUWwfzqCehDXUnC0/ylBaglmViwgUzD6Pu1yARq+4PKu43FOvrE4kqN4apqJ USBsMImsJgeAsDCS1jJ0QyT+yeJ5agRbEQSosTBq3LpSWUtBjBfmnktLuWaV8cYFpTfk OeSjA1fcm+ZGMYSAVD/sM9BEy5l9u0VlsSq6RnXLHONVNlzC7rvQQzQYOv/Z/O9/KgkF pzD0lm/QY/KBtwZOQTNBiVBBeCOoUQd3JRK04HfZxdz/C7nkl30KkPA/JsBKM1g+ma2I 0rK33lhXkLSWkZRuUfUjKqr1bTqjCET+kutB7TFkrblnZhg+1tWIhj4NJdysDYap+1ih dlLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=YB6oy9iPyQ2yGCx//M3l9HQNOZr7fMRdXmEHN9vRGxs=; b=tCoRVNeb97JBzR1Hqeyy4/7+7GNE4FRx2fknhUf7UtRmdArYyUN/tDF18aVqRLp+v7 dtXDYscdKed6Q8m/rJkiogXnJTA07xOKmpKHuiRPlcNR2FbLSK5I5aWTz1r0Ypct2+l4 oJSfRppz5m7J/qcdBSceMtWpcGIKSzTk7AITQHCUNR+K2SnFNS6QSQf8AMF7ZEH0pg+j 1iQ6XITByCPjrq70ay4uVQPN9Y2VaHi9iYwDAJeRl6OJ89QKM5DcaS21PYlw3kZ9o+AF aPql/enJ8fxoY/ejkncnxY3V5u6+OYxkVavxoMISFKDYwSOlOtZZuRNKV+ysDDNQBsZ+ 7EbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ezCj8/pg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a63cd07000000b0046ef5827384si4027810pgg.693.2022.10.27.23.41.26; Thu, 27 Oct 2022 23:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ezCj8/pg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbiJ1Ghb (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Fri, 28 Oct 2022 02:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbiJ1Gh3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Oct 2022 02:37:29 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC1419C06C for <linux-kernel@vger.kernel.org>; Thu, 27 Oct 2022 23:37:27 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so2863189wmb.0 for <linux-kernel@vger.kernel.org>; Thu, 27 Oct 2022 23:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=YB6oy9iPyQ2yGCx//M3l9HQNOZr7fMRdXmEHN9vRGxs=; b=ezCj8/pgbobEx97CDTJE8wIGRua7WNHJQfvq//ylU1KfxosyT8seGSaf6ThKBvPq9T F0YFLmtTHQlSceaoFI4PsTxZC/AJD/7s/ImXMxsTVeZ/xNcTjPSNOO5CY5AKoSwv9dnT Syjo8scfL++LpWrAp+KgxGjnda4fdytYDOORZ2GOpkGZSRff06Kd+Yzr5StN59W8MFm/ DsSH6v4wTsiES4x8/4twyFmgqL7XqMyKufwizOdLt/uga6VvrttVWT+29OerYoVWWrp7 prZ7wDb8PfwKQdfS64NVEaOjepOnxBS+TTnTG+yJNkX72g/H/5V6O2Vc75GiDKqYR+g7 Bpow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YB6oy9iPyQ2yGCx//M3l9HQNOZr7fMRdXmEHN9vRGxs=; b=AdHiBuBJ7lNuaBWc31BsHQrsp7in5KAEsNrE5jtbkvKV5jOFc1ib1LiWE+y4mJrE4k I8C37WMHYk3FnovjKlFvH0UnPGImZJ8kfjKGHDEWWDAgbAhOCOFRpHi9eoFlmvWHI0j1 F11jmZLUMG2q/bC5P2FduqONmXB0awx2tsK4eOmTJI4jwkep0dTrIU2HpIpZU/NeH9os gJNERt5RKhqD1M7m9TRqRvBKBuZR6RKuoyIPZ1obTa8xB9q4wCLf1KHYUMMpYaTDSEA6 7PMCknpj+UZ+PsvnPoHsj3ifTpUQduBpDjF5jp4W5YVPikUTl/tTQ+ysZXBGNKVRxLyi VHHQ== X-Gm-Message-State: ACrzQf2SC0N/byDmgQDqNfbeL/XUNWlPYZDsnf9p2ZfeU+4T2ULfu4De q3KQQ0o5jIGVTE5BzHIW9A8= X-Received: by 2002:a05:600c:46c7:b0:3c6:f3e6:1f13 with SMTP id q7-20020a05600c46c700b003c6f3e61f13mr8231687wmo.62.1666939045369; Thu, 27 Oct 2022 23:37:25 -0700 (PDT) Received: from rdm ([41.75.189.203]) by smtp.gmail.com with ESMTPSA id 4-20020a05600c26c400b003b31c560a0csm3218041wmv.12.2022.10.27.23.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 23:37:25 -0700 (PDT) Date: Fri, 28 Oct 2022 09:37:11 +0300 From: UMWARI JOVIAL <umwarijovial@gmail.com> To: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Subject: [PATCH] Remove Unnecessary typecast of c90 int constant Message-ID: <20221028063711.GA35659@rdm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747912543522872934?= X-GMAIL-MSGID: =?utf-8?q?1747912543522872934?= |
Series |
Remove Unnecessary typecast of c90 int constant
|
|
Commit Message
UMWARI JOVIAL
Oct. 28, 2022, 6:37 a.m. UTC
According to Linux kernel coding style.
Reported by checkpatch:
WARNING: Unnecessary typecast of c90 int constant - '(int)2.412e8' could be '2.412e8'
WARNING: Unnecessary typecast of c90 int constant - '(int)2.487e8' could be '2.487e8'
Signed-off-by: UMWARI JOVIAL <umwarijovial@gmail.com>
---
drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, 28 Oct 2022, UMWARI JOVIAL wrote: > According to Linux kernel coding style. > > Reported by checkpatch: > WARNING: Unnecessary typecast of c90 int constant - '(int)2.412e8' could be '2.412e8' > WARNING: Unnecessary typecast of c90 int constant - '(int)2.487e8' could be '2.487e8' It's not ideal to just include the checkpatch messges verbatim in your log message. It woudl be better to say what you are doing and why, in complete sentences ("According to the Linux coding style" is not a complete sentence). I also suspect that the checkpatch message is wrong. Floating point numbers cannot be used in the kernel, and the case of the constant ensures that the value will be converted to an integer at compile time. julia > > Signed-off-by: UMWARI JOVIAL <umwarijovial@gmail.com> > --- > drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c > index fdf867a5dd7a..4fc4fb25d8d6 100644 > --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c > +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c > @@ -41,8 +41,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, > > /* if setting by freq convert to channel */ > if (fwrq->e == 1) { > - if ((fwrq->m >= (int)2.412e8 && > - fwrq->m <= (int)2.487e8)) { > + if ((fwrq->m >= 2.412e8 && > + fwrq->m <= 2.487e8)) { > int f = fwrq->m / 100000; > int c = 0; > > -- > 2.25.1 > > >
let me again look in deep into it and see why Thank you for the comment On Fri, 28 Oct 2022 at 10:22, Julia Lawall <julia.lawall@inria.fr> wrote: > > > > On Fri, 28 Oct 2022, UMWARI JOVIAL wrote: > > > According to Linux kernel coding style. > > > > Reported by checkpatch: > > WARNING: Unnecessary typecast of c90 int constant - '(int)2.412e8' could be '2.412e8' > > WARNING: Unnecessary typecast of c90 int constant - '(int)2.487e8' could be '2.487e8' > > It's not ideal to just include the checkpatch messges verbatim in your log > message. It woudl be better to say what you are doing and why, in > complete sentences ("According to the Linux coding style" is not a > complete sentence). > > I also suspect that the checkpatch message is wrong. Floating point > numbers cannot be used in the kernel, and the case of the constant ensures > that the value will be converted to an integer at compile time. > > julia > > > > > Signed-off-by: UMWARI JOVIAL <umwarijovial@gmail.com> > > --- > > drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c > > index fdf867a5dd7a..4fc4fb25d8d6 100644 > > --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c > > +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c > > @@ -41,8 +41,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, > > > > /* if setting by freq convert to channel */ > > if (fwrq->e == 1) { > > - if ((fwrq->m >= (int)2.412e8 && > > - fwrq->m <= (int)2.487e8)) { > > + if ((fwrq->m >= 2.412e8 && > > + fwrq->m <= 2.487e8)) { > > int f = fwrq->m / 100000; > > int c = 0; > > > > -- > > 2.25.1 > > > > > >
From: Julia Lawall > Sent: 28 October 2022 08:23 > > On Fri, 28 Oct 2022, UMWARI JOVIAL wrote: > > > According to Linux kernel coding style. > > > > Reported by checkpatch: > > WARNING: Unnecessary typecast of c90 int constant - '(int)2.412e8' could be '2.412e8' > > WARNING: Unnecessary typecast of c90 int constant - '(int)2.487e8' could be '2.487e8' > > It's not ideal to just include the checkpatch messges verbatim in your log > message. It woudl be better to say what you are doing and why, in > complete sentences ("According to the Linux coding style" is not a > complete sentence). > > I also suspect that the checkpatch message is wrong. Floating point > numbers cannot be used in the kernel, and the case of the constant ensures > that the value will be converted to an integer at compile time. Much better to just use 241200000u (or 241200u * 1000 for readability). David > > julia > > > > > Signed-off-by: UMWARI JOVIAL <umwarijovial@gmail.com> > > --- > > drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c > b/drivers/staging/rtl8192e/rtllib_softmac_wx.c > > index fdf867a5dd7a..4fc4fb25d8d6 100644 > > --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c > > +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c > > @@ -41,8 +41,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, > > > > /* if setting by freq convert to channel */ > > if (fwrq->e == 1) { > > - if ((fwrq->m >= (int)2.412e8 && > > - fwrq->m <= (int)2.487e8)) { > > + if ((fwrq->m >= 2.412e8 && > > + fwrq->m <= 2.487e8)) { > > int f = fwrq->m / 100000; > > int c = 0; > > > > -- > > 2.25.1 > > > > > > - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Fri, 2022-10-28 at 09:22 +0200, Julia Lawall wrote: > > On Fri, 28 Oct 2022, UMWARI JOVIAL wrote: > > > According to Linux kernel coding style. > > > > Reported by checkpatch: > > WARNING: Unnecessary typecast of c90 int constant - '(int)2.412e8' could be '2.412e8' > > WARNING: Unnecessary typecast of c90 int constant - '(int)2.487e8' could be '2.487e8' > > It's not ideal to just include the checkpatch messges verbatim in your log > message. It woudl be better to say what you are doing and why, in > complete sentences ("According to the Linux coding style" is not a > complete sentence). > > I also suspect that the checkpatch message is wrong. Floating point > numbers cannot be used in the kernel, and the case of the constant ensures > that the value will be converted to an integer at compile time. Yes, it's a checkpatch defect. checkpatch should have this: --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4e187202e77a6..9958a774efaf1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6758,7 +6759,8 @@ sub process { } # check for cast of C90 native int or longer types constants - if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/) { + if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/ && + $2 !~ /^$Float$/) { my $cast = $1; my $const = $2; my $suffix = "";
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index fdf867a5dd7a..4fc4fb25d8d6 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -41,8 +41,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, /* if setting by freq convert to channel */ if (fwrq->e == 1) { - if ((fwrq->m >= (int)2.412e8 && - fwrq->m <= (int)2.487e8)) { + if ((fwrq->m >= 2.412e8 && + fwrq->m <= 2.487e8)) { int f = fwrq->m / 100000; int c = 0;