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

Mike Frysinger vapier at gentoo.org
Fri Sep 24 08:34:43 EDT 2010


On Fri, Sep 24, 2010 at 02:13, Jon Povey wrote:
> Mike Frysinger wrote:
>> 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
>
> you could do
> __attribute__((unused)) static type simple_##func(...
>
> I assume the compiler will still optimise them away, not sure.
>
> but with the 0xnn handling going away, does this header now offer
> much over just calling strtol et al directly?

that depends on whether you're comfortable breaking out your own
endptr and knowing the exact semantics
-mike



More information about the linux-mtd mailing list