From mboxrd@z Thu Jan 1 00:00:00 1970 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 7D8C7C433FE for ; Sat, 29 Oct 2022 14:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229853AbiJ2OiT convert rfc822-to-8bit (ORCPT ); Sat, 29 Oct 2022 10:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiJ2OiR (ORCPT ); Sat, 29 Oct 2022 10:38:17 -0400 Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3416CD0B for ; Sat, 29 Oct 2022 07:38:16 -0700 (PDT) Received: from omf12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 783E3C0110; Sat, 29 Oct 2022 14:38:14 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA id DCF0717; Sat, 29 Oct 2022 14:37:55 +0000 (UTC) Message-ID: Subject: Re: [PATCH] Remove Unnecessary typecast of c90 int constant From: Joe Perches To: Julia Lawall , UMWARI JOVIAL Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Date: Sat, 29 Oct 2022 07:38:10 -0700 In-Reply-To: References: <20221028063711.GA35659@rdm> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Rspamd-Queue-Id: DCF0717 X-Stat-Signature: 3kpugo777z3hb3xfdrd5mryxt7uasajh X-Rspamd-Server: rspamout02 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18BJ6iGaBQ/gDxUl5GMVObh7DN5jwxKBPo= X-HE-Tag: 1667054275-197456 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = "";