linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
@ 2017-07-10  7:09 AndyS
  2017-07-10 10:09 ` Frans Klaver
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: AndyS @ 2017-07-10  7:09 UTC (permalink / raw)
  To: gregkh; +Cc: me, devel, linux-kernel, shiva, AndyS

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

Signed-off-by: AndyS <lkd1024@mail.ru>
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 8aa12e813bd7..e176876665df 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -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;
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
  2017-07-10  7:09 [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed AndyS
@ 2017-07-10 10:09 ` Frans Klaver
  2017-07-10 10:31 ` kbuild test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Frans Klaver @ 2017-07-10 10:09 UTC (permalink / raw)
  To: AndyS; +Cc: Greg KH, driverdevel, shiva, linux-kernel

On Mon, Jul 10, 2017 at 9:09 AM, AndyS <lkd1024@mail.ru> wrote:
> Subject: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed

[PATCH] staging: ks7010: remove unneeded type casting

> removed undesired type casting. Warning was raised by checkpatch.pl
> This patch is for eudyptula challenge
>
> Signed-off-by: AndyS <lkd1024@mail.ru>

Use your real name, please.

> ---
>  drivers/staging/ks7010/ks_wlan_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
> index 8aa12e813bd7..e176876665df 100644
> --- a/drivers/staging/ks7010/ks_wlan_net.c
> +++ b/drivers/staging/ks7010/ks_wlan_net.c
> @@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
  2017-07-10  7:09 [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed AndyS
  2017-07-10 10:09 ` Frans Klaver
@ 2017-07-10 10:31 ` kbuild test robot
  2017-07-10 10:35 ` kbuild test robot
  2017-07-10 13:39 ` Joe Perches
  3 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2017-07-10 10:31 UTC (permalink / raw)
  To: AndyS; +Cc: kbuild-all, gregkh, devel, shiva, linux-kernel, AndyS

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 59367 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
  2017-07-10  7:09 [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed AndyS
  2017-07-10 10:09 ` Frans Klaver
  2017-07-10 10:31 ` kbuild test robot
@ 2017-07-10 10:35 ` kbuild test robot
  2017-07-10 13:39 ` Joe Perches
  3 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2017-07-10 10:35 UTC (permalink / raw)
  To: AndyS; +Cc: kbuild-all, gregkh, devel, shiva, linux-kernel, AndyS

[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]

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 <wsa+renesas@sang-engineering.com>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 50369 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
  2017-07-10  7:09 [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed AndyS
                   ` (2 preceding siblings ...)
  2017-07-10 10:35 ` kbuild test robot
@ 2017-07-10 13:39 ` Joe Perches
  2017-07-10 13:51   ` Joe Perches
  3 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2017-07-10 13:39 UTC (permalink / raw)
  To: AndyS, gregkh; +Cc: me, devel, linux-kernel, shiva

On Mon, 2017-07-10 at 10:09 +0300, AndyS wrote:
> 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.

> diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
[]
> @@ -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;
>  

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed
  2017-07-10 13:39 ` Joe Perches
@ 2017-07-10 13:51   ` Joe Perches
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2017-07-10 13:51 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft
  Cc: me, devel, linux-kernel, shiva, AndyS, gregkh

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",

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-10 13:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10  7:09 [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed AndyS
2017-07-10 10:09 ` Frans Klaver
2017-07-10 10:31 ` kbuild test robot
2017-07-10 10:35 ` kbuild test robot
2017-07-10 13:39 ` Joe Perches
2017-07-10 13:51   ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).