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

Jon Povey Jon.Povey at racelogic.co.uk
Fri Sep 24 00:31:26 EDT 2010


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?

> +       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.

--
Jon Povey
jon.povey at racelogic.co.uk

Racelogic is a limited company registered in England. Registered number 2743719 .
Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham, Bucks, MK18 1TB .

The information contained in this electronic mail transmission is intended by Racelogic Ltd for the use of the named individual or entity to which it is directed and may contain information that is confidential or privileged. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email so that the sender's address records can be corrected. The views expressed by the sender of this communication do not necessarily represent those of Racelogic Ltd. Please note that Racelogic reserves the right to monitor e-mail communications passing through its network





More information about the linux-mtd mailing list