* [PATCH 1/3] drivers: atm: use native kernel's hex_to_bin() func
@ 2010-09-20 23:27 Andy Shevchenko
2010-09-20 23:27 ` [PATCH 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
2010-09-20 23:27 ` [PATCH 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2010-09-20 23:27 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..dbce700 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] 3+ messages in thread
* [PATCH 2/3] sunrpc/cache: don't use custom hex_to_bin() converter
2010-09-20 23:27 [PATCH 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
@ 2010-09-20 23:27 ` Andy Shevchenko
2010-09-20 23:27 ` [PATCH 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2010-09-20 23:27 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] 3+ messages in thread
* [PATCH 3/3] net: core: use kernel's converter from hex to bin
2010-09-20 23:27 [PATCH 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
2010-09-20 23:27 ` [PATCH 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
@ 2010-09-20 23:27 ` Andy Shevchenko
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2010-09-20 23:27 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..168e3b6 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(*num);
+ 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] 3+ messages in thread
end of thread, other threads:[~2010-09-20 23:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-20 23:27 [PATCH 1/3] drivers: atm: use native kernel's hex_to_bin() func Andy Shevchenko
2010-09-20 23:27 ` [PATCH 2/3] sunrpc/cache: don't use custom hex_to_bin() converter Andy Shevchenko
2010-09-20 23:27 ` [PATCH 3/3] net: core: use kernel's converter from hex to bin Andy Shevchenko
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).