lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <efab1f11d5008188988813e3f3c27ce1297e71c0.camel@perches.com>
Date:   Sat, 29 Oct 2022 07:38:10 -0700
From:   Joe Perches <joe@...ches.com>
To:     Julia Lawall <julia.lawall@...ia.fr>,
        UMWARI JOVIAL <umwarijovial@...il.com>
Cc:     gregkh@...uxfoundation.org, linux-staging@...ts.linux.dev,
        linux-kernel@...r.kernel.org, outreachy@...ts.linux.dev
Subject: Re: [PATCH] Remove Unnecessary typecast of c90 int constant

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 = "";

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ