removed undesired type casting. Warning was raised by checkpatch.pl
This patch is for eudyptula challenge
Signed-off-by: AndyS <[email protected]>
---
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
On Mon, Jul 10, 2017 at 9:09 AM, AndyS <[email protected]> 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 <[email protected]>
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
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
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
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;
>
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 <[email protected]>
---
?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",