lkml.org 
[lkml]   [2002]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] hex <-> int conversion routines.
Jakob Kemi wrote:
> Hi,
>
> When grepping through the kernel I noticed that there exists at least 27
> (probably more with non-obvious names) different implementations of hex to
> int conversion functions. 2/3 of them in arch and the rest in drivers and fs.
> All implementations were variations of this function:

Fine...

> +static __inline__ int _hexint_byte(const char *src)
> +{

...

> +}

Not worth inlining. char conversion are seldomly time critical.


> +static __inline__ int hexint_nibble(char x)

Same applies here.

> +static __inline__ char inthex_nibble(int x)
> +{
> + const char* digits = "0123456789abcdef";
> +
> + return digits[x & 0x0f];
> +}

perhaps better do static const char *digits.

> +static __inline__ void inthex_byte(int x, char* dest)
> +{
> + const char* digits = "0123456789abcdef";
> +
> + dest[0] = digits[(x & 0xf0) >> 4];
> + dest[1] = digits[x & 0x0f];
> +}

perhaps better do static const char *digits.

Regards.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:18    [W:0.072 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site