* [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func
@ 2010-09-21 6:40 Andy Shevchenko
2010-09-21 6:40 ` [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2010-09-21 6:40 UTC (permalink / raw
To: linux-kernel
Cc: David S. Miller, netdev, Andy Shevchenko, Chas Williams,
linux-atm-general
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Chas Williams <chas@cmf.nrl.navy.mil>
Cc: linux-atm-general@lists.sourceforge.net
---
drivers/atm/horizon.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index 54720ba..a957904 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -1645,10 +1645,8 @@ static int hrz_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
unsigned short d = 0;
char * s = skb->data;
if (*s++ == 'D') {
- for (i = 0; i < 4; ++i) {
- d = (d<<4) | ((*s <= '9') ? (*s - '0') : (*s - 'a' + 10));
- ++s;
- }
+ for (i = 0; i < 4; ++i)
+ d = (d << 4) | hex_to_bin(*s++);
PRINTK (KERN_INFO, "debug bitmap is now %hx", debug = d);
}
}
--
1.7.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter
2010-09-21 6:40 [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
@ 2010-09-21 6:40 ` Andy Shevchenko
2010-09-22 1:08 ` David Miller
2010-09-22 19:03 ` J. Bruce Fields
2010-09-21 6:40 ` [PATCHv1.5 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
2010-09-22 1:07 ` [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func David Miller
2 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2010-09-21 6:40 UTC (permalink / raw
To: linux-kernel
Cc: David S. Miller, netdev, Andy Shevchenko, Trond Myklebust,
linux-nfs
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org
---
net/sunrpc/cache.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 5b7b56f..c944a24 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1171,13 +1171,19 @@ int qword_get(char **bpp, char *dest, int bufsize)
if (bp[0] == '\\' && bp[1] == 'x') {
/* HEX STRING */
bp += 2;
- while (isxdigit(bp[0]) && isxdigit(bp[1]) && len < bufsize) {
- int byte = isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10;
- bp++;
- byte <<= 4;
- byte |= isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10;
- *dest++ = byte;
- bp++;
+ while (len < bufsize) {
+ int h, l;
+
+ h = hex_to_bin(bp[0]);
+ if (h < 0)
+ break;
+
+ l = hex_to_bin(bp[1]);
+ if (l < 0)
+ break;
+
+ *dest++ = (h << 4) | l;
+ bp += 2;
len++;
}
} else {
--
1.7.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCHv1.5 3/3] net: core: use kernel's converter from hex to bin
2010-09-21 6:40 [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
2010-09-21 6:40 ` [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
@ 2010-09-21 6:40 ` Andy Shevchenko
2010-09-22 1:08 ` David Miller
2010-09-22 1:07 ` [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func David Miller
2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2010-09-21 6:40 UTC (permalink / raw
To: linux-kernel; +Cc: David S. Miller, netdev, Andy Shevchenko
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
net/core/pktgen.c | 10 ++++------
net/core/utils.c | 13 +++++++------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 386c228..2c0df0f 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -729,16 +729,14 @@ static int hex32_arg(const char __user *user_buffer, unsigned long maxlen,
*num = 0;
for (; i < maxlen; i++) {
+ int value;
char c;
*num <<= 4;
if (get_user(c, &user_buffer[i]))
return -EFAULT;
- if ((c >= '0') && (c <= '9'))
- *num |= c - '0';
- else if ((c >= 'a') && (c <= 'f'))
- *num |= c - 'a' + 10;
- else if ((c >= 'A') && (c <= 'F'))
- *num |= c - 'A' + 10;
+ value = hex_to_bin(c);
+ if (value >= 0)
+ *num |= value;
else
break;
}
diff --git a/net/core/utils.c b/net/core/utils.c
index f418544..ec6bb32 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -92,18 +92,19 @@ EXPORT_SYMBOL(in_aton);
static inline int xdigit2bin(char c, int delim)
{
+ int val;
+
if (c == delim || c == '\0')
return IN6PTON_DELIM;
if (c == ':')
return IN6PTON_COLON_MASK;
if (c == '.')
return IN6PTON_DOT;
- if (c >= '0' && c <= '9')
- return (IN6PTON_XDIGIT | IN6PTON_DIGIT| (c - '0'));
- if (c >= 'a' && c <= 'f')
- return (IN6PTON_XDIGIT | (c - 'a' + 10));
- if (c >= 'A' && c <= 'F')
- return (IN6PTON_XDIGIT | (c - 'A' + 10));
+
+ val = hex_to_bin(c);
+ if (val >= 0)
+ return val | IN6PTON_XDIGIT | (val < 10 ? IN6PTON_DIGIT : 0);
+
if (delim == -1)
return IN6PTON_DELIM;
return IN6PTON_UNKNOWN;
--
1.7.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func
2010-09-21 6:40 [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
2010-09-21 6:40 ` [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
2010-09-21 6:40 ` [PATCHv1.5 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
@ 2010-09-22 1:07 ` David Miller
2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2010-09-22 1:07 UTC (permalink / raw
To: andy.shevchenko; +Cc: linux-kernel, netdev, chas, linux-atm-general
From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Tue, 21 Sep 2010 09:40:24 +0300
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Chas Williams <chas@cmf.nrl.navy.mil>
> Cc: linux-atm-general@lists.sourceforge.net
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter
2010-09-21 6:40 ` [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
@ 2010-09-22 1:08 ` David Miller
2010-09-22 19:03 ` J. Bruce Fields
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2010-09-22 1:08 UTC (permalink / raw
To: andy.shevchenko; +Cc: linux-kernel, netdev, Trond.Myklebust, linux-nfs
From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Tue, 21 Sep 2010 09:40:25 +0300
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
> Cc: linux-nfs@vger.kernel.org
I'll let the NFS folks pick this one up.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHv1.5 3/3] net: core: use kernel's converter from hex to bin
2010-09-21 6:40 ` [PATCHv1.5 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
@ 2010-09-22 1:08 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2010-09-22 1:08 UTC (permalink / raw
To: andy.shevchenko; +Cc: linux-kernel, netdev
From: Andy Shevchenko <andy.shevchenko@gmail.com>
Date: Tue, 21 Sep 2010 09:40:26 +0300
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter
2010-09-21 6:40 ` [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
2010-09-22 1:08 ` David Miller
@ 2010-09-22 19:03 ` J. Bruce Fields
1 sibling, 0 replies; 7+ messages in thread
From: J. Bruce Fields @ 2010-09-22 19:03 UTC (permalink / raw
To: Andy Shevchenko
Cc: linux-kernel, David S. Miller, netdev, Trond Myklebust, linux-nfs
On Tue, Sep 21, 2010 at 09:40:25AM +0300, Andy Shevchenko wrote:
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
> Cc: linux-nfs@vger.kernel.org
Thanks, applied for 2.6.37.
--b.
> ---
> net/sunrpc/cache.c | 20 +++++++++++++-------
> 1 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
> index 5b7b56f..c944a24 100644
> --- a/net/sunrpc/cache.c
> +++ b/net/sunrpc/cache.c
> @@ -1171,13 +1171,19 @@ int qword_get(char **bpp, char *dest, int bufsize)
> if (bp[0] == '\\' && bp[1] == 'x') {
> /* HEX STRING */
> bp += 2;
> - while (isxdigit(bp[0]) && isxdigit(bp[1]) && len < bufsize) {
> - int byte = isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10;
> - bp++;
> - byte <<= 4;
> - byte |= isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10;
> - *dest++ = byte;
> - bp++;
> + while (len < bufsize) {
> + int h, l;
> +
> + h = hex_to_bin(bp[0]);
> + if (h < 0)
> + break;
> +
> + l = hex_to_bin(bp[1]);
> + if (l < 0)
> + break;
> +
> + *dest++ = (h << 4) | l;
> + bp += 2;
> len++;
> }
> } else {
> --
> 1.7.2.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-09-22 19:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-21 6:40 [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
2010-09-21 6:40 ` [PATCHv1.5 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
2010-09-22 1:08 ` David Miller
2010-09-22 19:03 ` J. Bruce Fields
2010-09-21 6:40 ` [PATCHv1.5 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
2010-09-22 1:08 ` David Miller
2010-09-22 1:07 ` [PATCHv1.5 1/3] drivers: atm: use native kernel's hex_to_bin() func David Miller
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 read-only IMAP folder(s) and NNTP newsgroup(s).