login
Header Space

 
 

Re: [PATCH 12/12] net: use the common ascii hex helpers

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Harvey Harrison <harvey.harrison@...>
Cc: <davem@...>, <linux-kernel@...>
Date: Friday, May 2, 2008 - 8:30 pm

On Fri, 02 May 2008 17:15:55 -0700
Harvey Harrison <harvey.harrison@gmail.com> wrote:


I dunno.  Return-by-reference is a bit nasty and forces the compiler to
generate extra code to put local storage into a stack slot rather than
keeping it in a register.


Does anyone actually test whether hex_to_foo returns -1?  Probably not
many.

In which case it might be better to do

u64 hex_to_u64(const char *buf);

and, if we encounter a non-hex char, do a WARN_ON(1).


One could legitimately do

	int c = hex_to_int(some_user_input);
	if (c < 0) {
		printk("user: you're an idiot\n");
	}

to perform validation and conversion in a single operation but I expect
that such code is in the minority, and could be covered by running a separate

bool is_hex_string(const char *bug, size_t nchars);

beforehand?
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 12/12] net: use the common ascii hex helpers, Harvey Harrison, (Fri May 2, 3:01 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Andrew Morton, (Fri May 2, 7:31 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Harvey Harrison, (Fri May 2, 7:52 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Andrew Morton, (Fri May 2, 8:08 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Harvey Harrison, (Fri May 2, 8:15 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Andrew Morton, (Fri May 2, 8:30 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Harvey Harrison, (Fri May 2, 8:11 pm)
Re: [PATCH 12/12] net: use the common ascii hex helpers, Andrew Morton, (Fri May 2, 7:43 pm)
speck-geostationary