Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1684271

Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
Date 2017-07-10 16:00 +0200
Message-ID <u1Hog-5IV-65@gated-at.bofh.it> (permalink)
References <u1CeR-2AZ-3@gated-at.bofh.it> <u1Hey-5Fo-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


A floating point constant cast to an int was giving
a false positive warning about unneeded cast to int.

e.g.:

	(fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8))

Fix it.

Though it's probably better to avoid float/double values
that are cast to int at all.

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2287a0bca863..cbd99c22e2f6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5673,7 +5673,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;
 			if (WARN("TYPECAST_INT_CONSTANT",

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed AndyS <lkd1024@mail.ru> - 2017-07-10 10:30 +0200
  Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed Frans Klaver <fransklaver@gmail.com> - 2017-07-10 12:20 +0200
  Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting  removed Joe Perches <joe@perches.com> - 2017-07-10 15:50 +0200
    Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting  removed Joe Perches <joe@perches.com> - 2017-07-10 16:00 +0200

csiph-web