[PATCH 3/4] mtd-utils: new strtoX helpers

Mike Frysinger vapier at gentoo.org
Fri Sep 24 01:35:34 EDT 2010


On Fri, Sep 24, 2010 at 00:31, Jon Povey wrote:
> linux-mtd-bounces at lists.infradead.org wrote:
>> Simply usage of converting strings to numbers by adding some wrappers
>> around the standard strtoX functions.  These helpers support both hex
>> and dec numbers transparently, and the caller need only provide a ptr
>> to an error integer if they want to be notified of problems.
>
>> + */ +#define simple_strtoX(func, type) \
>> +static inline type simple_##func(const char *snum, int *error) \ +{ \
>
> Why inline? won't this bloat code, better to remove inline?

because uninlined static definitions will generate unused warnings

>> +       if (snum[0] == '0' && snum[1] == 'x') \
>> +               ret = func(snum, &endptr, 16); \
>> +       else \
>> +               ret = func(snum, &endptr, 10); \
>
> Can just call strtol etc. with 0 instead of 10 or 16, it will autodetect
> 0xnnn as base 16.

true ... i'll fix that up
-mike



More information about the linux-mtd mailing list