* [PATCH 1/2] net: core: let's use native isxdigit instead of custom
@ 2013-03-27 15:54 Andy Shevchenko
2013-03-27 15:54 ` [PATCH 2/2] ppp: reuse print_hex_dump_bytes Andy Shevchenko
2013-03-27 17:09 ` [PATCH 1/2] net: core: let's use native isxdigit instead of custom David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-03-27 15:54 UTC (permalink / raw)
To: Paul Mackerras, David S. Miller, linux-ppp, netdev; +Cc: Andy Shevchenko
In kernel we have fast and pretty implementation of the isxdigit() function.
Let's use it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
net/core/utils.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/core/utils.c b/net/core/utils.c
index e3487e46..3c7f5b5 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -17,6 +17,7 @@
#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
+#include <linux/ctype.h>
#include <linux/inet.h>
#include <linux/mm.h>
#include <linux/net.h>
@@ -348,9 +349,7 @@ int mac_pton(const char *s, u8 *mac)
/* Don't dirty result unless string is valid MAC. */
for (i = 0; i < ETH_ALEN; i++) {
- if (!strchr("0123456789abcdefABCDEF", s[i * 3]))
- return 0;
- if (!strchr("0123456789abcdefABCDEF", s[i * 3 + 1]))
+ if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
return 0;
if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
return 0;
--
1.8.2.rc0.22.gb3600c3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ppp: reuse print_hex_dump_bytes
2013-03-27 15:54 [PATCH 1/2] net: core: let's use native isxdigit instead of custom Andy Shevchenko
@ 2013-03-27 15:54 ` Andy Shevchenko
2013-03-27 17:09 ` David Miller
2013-03-27 17:09 ` [PATCH 1/2] net: core: let's use native isxdigit instead of custom David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2013-03-27 15:54 UTC (permalink / raw)
To: Paul Mackerras, David S. Miller, linux-ppp, netdev; +Cc: Andy Shevchenko
There is a native function to dump hex buffers.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/net/ppp/ppp_synctty.c | 53 ++-----------------------------------------
1 file changed, 2 insertions(+), 51 deletions(-)
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index bdf3b13..925d3e2 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -105,64 +105,15 @@ static const struct ppp_channel_ops sync_ops = {
};
/*
- * Utility procedures to print a buffer in hex/ascii
+ * Utility procedure to print a buffer in hex/ascii
*/
static void
-ppp_print_hex (register __u8 * out, const __u8 * in, int count)
-{
- register __u8 next_ch;
- static const char hex[] = "0123456789ABCDEF";
-
- while (count-- > 0) {
- next_ch = *in++;
- *out++ = hex[(next_ch >> 4) & 0x0F];
- *out++ = hex[next_ch & 0x0F];
- ++out;
- }
-}
-
-static void
-ppp_print_char (register __u8 * out, const __u8 * in, int count)
-{
- register __u8 next_ch;
-
- while (count-- > 0) {
- next_ch = *in++;
-
- if (next_ch < 0x20 || next_ch > 0x7e)
- *out++ = '.';
- else {
- *out++ = next_ch;
- if (next_ch = '%') /* printk/syslogd has a bug !! */
- *out++ = '%';
- }
- }
- *out = '\0';
-}
-
-static void
ppp_print_buffer (const char *name, const __u8 *buf, int count)
{
- __u8 line[44];
-
if (name != NULL)
printk(KERN_DEBUG "ppp_synctty: %s, count = %d\n", name, count);
- while (count > 8) {
- memset (line, 32, 44);
- ppp_print_hex (line, buf, 8);
- ppp_print_char (&line[8 * 3], buf, 8);
- printk(KERN_DEBUG "%s\n", line);
- count -= 8;
- buf += 8;
- }
-
- if (count > 0) {
- memset (line, 32, 44);
- ppp_print_hex (line, buf, count);
- ppp_print_char (&line[8 * 3], buf, count);
- printk(KERN_DEBUG "%s\n", line);
- }
+ print_hex_dump_bytes("", DUMP_PREFIX_NONE, buf, count);
}
--
1.8.2.rc0.22.gb3600c3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] net: core: let's use native isxdigit instead of custom
2013-03-27 15:54 [PATCH 1/2] net: core: let's use native isxdigit instead of custom Andy Shevchenko
2013-03-27 15:54 ` [PATCH 2/2] ppp: reuse print_hex_dump_bytes Andy Shevchenko
@ 2013-03-27 17:09 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2013-03-27 17:09 UTC (permalink / raw)
To: andriy.shevchenko; +Cc: paulus, linux-ppp, netdev
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Wed, 27 Mar 2013 17:54:13 +0200
> In kernel we have fast and pretty implementation of the isxdigit() function.
> Let's use it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ppp: reuse print_hex_dump_bytes
2013-03-27 15:54 ` [PATCH 2/2] ppp: reuse print_hex_dump_bytes Andy Shevchenko
@ 2013-03-27 17:09 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-03-27 17:09 UTC (permalink / raw)
To: andriy.shevchenko; +Cc: paulus, linux-ppp, netdev
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Wed, 27 Mar 2013 17:54:14 +0200
> There is a native function to dump hex buffers.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-27 17:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-27 15:54 [PATCH 1/2] net: core: let's use native isxdigit instead of custom Andy Shevchenko
2013-03-27 15:54 ` [PATCH 2/2] ppp: reuse print_hex_dump_bytes Andy Shevchenko
2013-03-27 17:09 ` David Miller
2013-03-27 17:09 ` [PATCH 1/2] net: core: let's use native isxdigit instead of custom 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 NNTP newsgroup(s).