* [PATCH] net: wireless: atmel: Remove open-coded and wrong strcasecmp
@ 2015-01-16 13:28 Rasmus Villemoes
2015-01-16 18:17 ` Sergei Shtylyov
2015-01-21 11:52 ` [PATCH v2] " Rasmus Villemoes
0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2015-01-16 13:28 UTC (permalink / raw)
To: Simon Kelley, Kalle Valo
Cc: Rasmus Villemoes, linux-wireless, netdev, linux-kernel
The kernel's string library does in fact have strcasecmp, at least
since ded220bd8f08. Moreover, this open-coded version is in fact
wrong: If the strings only differ in their last character, a and b
have already been incremented to point to the terminating nul bytes,
so they would be treated as equal.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/net/wireless/atmel.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 9183f1cf89a7..55db9f03eb2a 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -45,7 +45,6 @@
#include <linux/ptrace.h>
#include <linux/slab.h>
#include <linux/string.h>
-#include <linux/ctype.h>
#include <linux/timer.h>
#include <asm/byteorder.h>
#include <asm/io.h>
@@ -2699,16 +2698,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
domain[REGDOMAINSZ] = 0;
rc = -EINVAL;
for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
- /* strcasecmp doesn't exist in the library */
- char *a = channel_table[i].name;
- char *b = domain;
- while (*a) {
- char c1 = *a++;
- char c2 = *b++;
- if (tolower(c1) != tolower(c2))
- break;
- }
- if (!*a && !*b) {
+ if (!strcasecmp(channel_table[i].name, domain)) {
priv->config_reg_domain = channel_table[i].reg_domain;
rc = 0;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: wireless: atmel: Remove open-coded and wrong strcasecmp
2015-01-16 13:28 [PATCH] net: wireless: atmel: Remove open-coded and wrong strcasecmp Rasmus Villemoes
@ 2015-01-16 18:17 ` Sergei Shtylyov
2015-01-21 11:52 ` [PATCH v2] " Rasmus Villemoes
1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-01-16 18:17 UTC (permalink / raw)
To: Rasmus Villemoes, Simon Kelley, Kalle Valo
Cc: linux-wireless, netdev, linux-kernel
Hello.
On 01/16/2015 04:28 PM, Rasmus Villemoes wrote:
> The kernel's string library does in fact have strcasecmp, at least
> since ded220bd8f08. Moreover, this open-coded version is in fact
Please also specify that commit's summary line in parens.
> wrong: If the strings only differ in their last character, a and b
> have already been incremented to point to the terminating nul bytes,
NUL.
> so they would be treated as equal.
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] net: wireless: atmel: Remove open-coded and wrong strcasecmp
2015-01-16 13:28 [PATCH] net: wireless: atmel: Remove open-coded and wrong strcasecmp Rasmus Villemoes
2015-01-16 18:17 ` Sergei Shtylyov
@ 2015-01-21 11:52 ` Rasmus Villemoes
2015-01-23 19:40 ` [v2] " Kalle Valo
1 sibling, 1 reply; 4+ messages in thread
From: Rasmus Villemoes @ 2015-01-21 11:52 UTC (permalink / raw)
To: Simon Kelley, Kalle Valo
Cc: Sergei Shtylyov, Rasmus Villemoes, linux-wireless, netdev, linux-kernel
The kernel's string library does in fact have strcasecmp, at least
since ded220bd8f08 ("[STRING]: Move strcasecmp/strncasecmp to
lib/string.c"). Moreover, this open-coded version is in fact wrong: If
the strings only differ in their last character, a and b have already
been incremented to point to the terminating NUL bytes, so they would
wrongly be treated as equal.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
v2: Address Sergei's comments to the commit message.
drivers/net/wireless/atmel.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 9183f1cf89a7..55db9f03eb2a 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -45,7 +45,6 @@
#include <linux/ptrace.h>
#include <linux/slab.h>
#include <linux/string.h>
-#include <linux/ctype.h>
#include <linux/timer.h>
#include <asm/byteorder.h>
#include <asm/io.h>
@@ -2699,16 +2698,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
domain[REGDOMAINSZ] = 0;
rc = -EINVAL;
for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
- /* strcasecmp doesn't exist in the library */
- char *a = channel_table[i].name;
- char *b = domain;
- while (*a) {
- char c1 = *a++;
- char c2 = *b++;
- if (tolower(c1) != tolower(c2))
- break;
- }
- if (!*a && !*b) {
+ if (!strcasecmp(channel_table[i].name, domain)) {
priv->config_reg_domain = channel_table[i].reg_domain;
rc = 0;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [v2] atmel: Remove open-coded and wrong strcasecmp
2015-01-21 11:52 ` [PATCH v2] " Rasmus Villemoes
@ 2015-01-23 19:40 ` Kalle Valo
0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2015-01-23 19:40 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Simon Kelley, Sergei Shtylyov, Rasmus Villemoes, linux-wireless,
netdev, linux-kernel
> The kernel's string library does in fact have strcasecmp, at least
> since ded220bd8f08 ("[STRING]: Move strcasecmp/strncasecmp to
> lib/string.c"). Moreover, this open-coded version is in fact wrong: If
> the strings only differ in their last character, a and b have already
> been incremented to point to the terminating NUL bytes, so they would
> wrongly be treated as equal.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Thanks, applied to wireless-drivers-next.git. I just remove the useless "net:
wireless:" from the title. People, PLEASE stop using that.
Kalle Valo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-23 19:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16 13:28 [PATCH] net: wireless: atmel: Remove open-coded and wrong strcasecmp Rasmus Villemoes
2015-01-16 18:17 ` Sergei Shtylyov
2015-01-21 11:52 ` [PATCH v2] " Rasmus Villemoes
2015-01-23 19:40 ` [v2] " Kalle Valo
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).