Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1684046 > unrolled thread
| Started by | AndyS <lkd1024@mail.ru> |
|---|---|
| First post | 2017-07-10 10:30 +0200 |
| Last post | 2017-07-10 16:00 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[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
| From | AndyS <lkd1024@mail.ru> |
|---|---|
| Date | 2017-07-10 10:30 +0200 |
| Subject | [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed |
| Message-ID | <u1CeR-2AZ-3@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Frans Klaver <fransklaver@gmail.com> |
|---|---|
| Date | 2017-07-10 12:20 +0200 |
| Message-ID | <u1DXj-3Ma-5@gated-at.bofh.it> |
| In reply to | #1684046 |
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
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-07-10 15:50 +0200 |
| Subject | Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed |
| Message-ID | <u1Hey-5Fo-27@gated-at.bofh.it> |
| In reply to | #1684046 |
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;
>
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-07-10 16:00 +0200 |
| Subject | Re: [PATCH] Staging:ks7010:ks_wlan_net.c: unneeded type casting removed |
| Message-ID | <u1Hog-5IV-65@gated-at.bofh.it> |
| In reply to | #1684255 |
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",
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web