All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Harvey Harrison <harvey.harrison@gmail.com>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 12/12] net: use the common ascii hex helpers
Date: Fri, 2 May 2008 17:08:02 -0700	[thread overview]
Message-ID: <20080502170802.456493a5.akpm@linux-foundation.org> (raw)
In-Reply-To: <1209772363.26173.101.camel@brick>

On Fri, 02 May 2008 16:52:43 -0700
Harvey Harrison <harvey.harrison@gmail.com> wrote:

> On Fri, 2008-05-02 at 16:31 -0700, Andrew Morton wrote:
> > On Fri, 02 May 2008 16:25:15 -0700 (PDT)
> > David Miller <davem@davemloft.net> wrote:
> > 
> > > From: Harvey Harrison <harvey.harrison@gmail.com>
> > > Date: Fri, 02 May 2008 12:01:56 -0700
> > > 
> > > > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> > > 
> > > Acked-by: David S. Miller <davem@davemloft.net>
> > > 
> > > This has to go in via who ever adds the first patch
> > > with the actual helpers, so I won't apply this one.
> > 
> > Yup.  After a bit of testing and tyre-kicking I'll probably slip
> > lib-add-ascii-hex-helper-functions.patch into mainline so that we can
> > trickle all the *-use-the-common-ascii-hex-helpers.patch patches out to the
> > various maintainers.
> > 
> 
> I suppose the hex_asc array and hex_to_int could also use
> EXPORT_SYMBOL().

gack.  How could you do all those patches without discovering this?  Please
go give your QA staff a wedgie.

--- a/lib/hexdump.c~lib-add-ascii-hex-helper-functions-fix
+++ a/lib/hexdump.c
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 
 const char hex_asc[] = "0123456789abcdef";
+EXPORT_SYMBOL(hex_asc);
 
 /**
  * hex_to_int - convert a single hex ASCII char to an integer value
@@ -32,6 +33,7 @@ int hex_to_int(char ch)
 		return ch - '0';
 	return -1;
 }
+EXPORT_SYMBOL(hex_to_int);
 
 /**
  * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
_


> Also, As I've looked further around the tree, there seem to be a lot
> of hex_to_int/long variants around the tree, so what I'm thinking is
> the current hex_to_int becomes hex_to_u8 and I'll add a:
> 
> /**
>  * hex_to_u32 - read a u32 from a char buffer
>  * @buf: buffer to read ascii chars from
>  * @val: where to put the u32
>  *
>  * Read hex-ascii chars into a u32.  Return the number of chars read.
>  * A maximum of 8 chars will be read, if a char not in [a-f][A-F][0-9]
>  * is encountered, the function returns.
>  */
> int hex_to_u32(const char *buf, u32 *val)
> 
> Similar to the above, but a max of 16 chars will be read.
> int hex_to_u64(const char *buf, u64 *val)
> 
> If this api is better, I suppose:
> 
> int hex_to_u8 - max of two chars
> int hex_to_u16 - max of 4
> int hex_to_u32 - max of 8
> int hex_to_u64 - max of 16
> 
> Could be added around a common function that takes the max length as
> an additional arg.
> 

yes, hex_to_u8() is more specific and better defined than hex_to_int().

Although anally it should perhaps be two_digit_hex_to_ulong,
four_digit_hex_to_ulong, etc.

ho hum, I'll drop them all.



  reply	other threads:[~2008-05-03  0:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-02 19:01 [PATCH 12/12] net: use the common ascii hex helpers Harvey Harrison
2008-05-02 23:25 ` David Miller
2008-05-02 23:31   ` Andrew Morton
2008-05-02 23:39     ` David Miller
2008-05-02 23:43       ` Andrew Morton
2008-05-02 23:52     ` Harvey Harrison
2008-05-03  0:08       ` Andrew Morton [this message]
2008-05-03  0:11         ` Harvey Harrison
2008-05-03  0:15         ` Harvey Harrison
2008-05-03  0:30           ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080502170802.456493a5.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=harvey.harrison@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.