Skip to contentSkip to conversation

Staging:ks7010:ks_wlan_net.c: unneeded type casting removed

PATCH In review AndyS 4 participants 6 messages Jul 10, 2017

Subsystems (2)
lore
Share & tools
lore

AndyS

author
#0 lore raw

PATCH 1/1 Staging:ks7010:ks_wlan_net.c: unneeded type casting removed

removed undesired type casting. Warning was raised by checkpatch.pl This patch is for eudyptula challenge

---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/ks7010/ks_wlan_net.c +1 -1
index 8aa12e813bd7..e176876665df 100644
@@ -208,7 +208,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 	/* for SLEEP MODE */
 	/* If setting by frequency, convert to a channel */
 	if ((fwrq->e == 1) &&
-	    (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) {
+	    (fwrq->m >= 2.412e8) && (fwrq->m <= 2.487e8)) {
 		int f = fwrq->m / 100000;
 		int c = 0;
 
Signature · 1 line
2.13.0
#1 lore raw
Quoted 1 line · AndyS

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

[PATCH] staging: ks7010: remove unneeded type casting

Quoted 4 lines

removed undesired type casting. Warning was raised by checkpatch.pl This patch is for eudyptula challenge

Use your real name, please.

Quoted 9 lines
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/ks7010/ks_wlan_net.c +0 -0
index 8aa12e813bd7..e176876665df 100644

drivers/staging/ks7010/ks_wlan_net.c static int ks_wlan_set_freq(struct net_device *dev, · line 211

Quoted 5 lines
drivers/staging/ks7010/ks_wlan_net.c +1 -1
@@ -208,7 +208,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
        /* for SLEEP MODE */
        /* If setting by frequency, convert to a channel */
        if ((fwrq->e == 1) &&
-           (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) {
+           (fwrq->m >= 2.412e8) && (fwrq->m <= 2.487e8)) {

Do we really want to compare against a double value?

Frans

#2 lore raw
In reply to AndyS
url: https://github.com/0day-ci/linux/commits/AndyS/Staging-ks7010-ks_wlan_net-c-unneeded-type-casting-removed/20170710-172848 config: x86_64-allyesconfig (attached as .config) compiler: gcc-6…

Hi AndyS,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.12 next-20170710]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/AndyS/Staging-ks7010-ks_wlan_net-c-unneeded-type-casting-removed/20170710-172848
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/staging/ks7010/ks_wlan_net.c: In function 'ks_wlan_set_freq':

>> drivers/staging/ks7010/ks_wlan_net.c:211:15: error: SSE register return with SSE disabled
         (fwrq->m >= 2.412e8) && (fwrq->m <= 2.487e8)) {
         ~~~~~~~~~^~~~~~~~~~~

vim +211 drivers/staging/ks7010/ks_wlan_net.c

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to AndyS
url: https://github.com/0day-ci/linux/commits/AndyS/Staging-ks7010-ks_wlan_net-c-unneeded-type-casting-removed/20170710-172848 config: alpha-allyesconfig (attached as .config) compiler…

Hi AndyS,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.12 next-20170710]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/AndyS/Staging-ks7010-ks_wlan_net-c-unneeded-type-casting-removed/20170710-172848
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha

All errors (new ones prefixed by >>):

drivers/staging/ks7010/ks_wlan_net.c: In function 'ks_wlan_set_freq':
drivers/staging/ks7010/ks_wlan_net.c:240:1: error: insn does not satisfy its constraints:

    }
    ^
   (insn 291 46 292 4 (set (mem/c:DF (plus:DI (reg/f:DI 30 $30)
                   (const_int 80 [0x50])) [0  S8 A64])
           (reg:DF 32 $f0)) drivers/staging/ks7010/ks_wlan_net.c:211 227 {*movdf}
        (nil))
>> drivers/staging/ks7010/ks_wlan_net.c:240:1: internal compiler error: in extract_constrain_insn, at recog.c:2190

Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.

vim +240 drivers/staging/ks7010/ks_wlan_net.c

:::::: The code at line 240 was first introduced by commit
:::::: 13a9930d15b424ab7d3b906af8ba7ff8c409edfe staging: ks7010: add driver from Nanonote extra-repository

:::::: TO: Wolfram Sang <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

maintainer
#4 lore raw
In reply to AndyS
Quoted 2 lines · AndyS

removed undesired type casting. Warning was raised by checkpatch.pl This patch is for eudyptula challenge

False positive in checkpatch.
checkpatch does not handle floating point values.

drivers/staging/ks7010/ks_wlan_net.c

Quoted 1 line
drivers/staging/ks7010/ks_wlan_net.c +0 -0

[]

Quoted 9 lines
drivers/staging/ks7010/ks_wlan_net.c +1 -1
@@ -208,7 +208,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 	/* for SLEEP MODE */
 	/* If setting by frequency, convert to a channel */
 	if ((fwrq->e == 1) &&
-	    (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) {
+	    (fwrq->m >= 2.412e8) && (fwrq->m <= 2.487e8)) {
 		int f = fwrq->m / 100000;
 		int c = 0;
 
maintainer
#5 lore 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.

---
 scripts/checkpatch.pl | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +0 -0
index 2287a0bca863..cbd99c22e2f6 100755
@@ -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",