Skip to content

kstrtox: make _parse_integer() flexible

Andy Shevchenko lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2kstrtox: Make _parse_integer() take variadic argumentslib/kstrtox.c lib/kstrtox.h+8 -75 replies
2/2vsprintf: Convert to use _parse_integer() instead of _parse_integer_limit()lib/kstrtox.h lib/vsprintf.c+4 -10 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPetr Mladek
SeriesA-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 0/2] kstrtox: make _parse_integer() flexible

Currently every new wrapper on _parse_integer_limit() will need a new name to share with users while keeping some optional arguments to be initialised explicitly. Since there is an attempt to expand this more, I decided to suggest this mini series to avoid namespace pollution and unneeded churn in the future.

To expand this API more, the possible future change may be:

unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *res,
- size_t max_chars);
+ size_t max_chars, $new_opt_arg);

#define _parse_integer0(s, base, res, ...) \
- _parse_integer_limit(s, base, res, INT_MAX);
+ _parse_integer_limit(s, base, res, INT_MAX, $new_opt_arg=$default);

#define _parse_integer1(s, base, res, max_chars, ...) \
- _parse_integer_limit(s, base, res, max_chars);
+ _parse_integer_limit(s, base, res, max_chars, $new_opt_arg=$default);

+#define _parse_integer2(s, base, res, max_chars, new_opt_arg, ...) \
+ _parse_integer_limit(s, base, res, max_chars, new_opt_arg);

So you got the idea. (It is roughly overloaded function in OOP.)

Andy Shevchenko (2):
kstrtox: Make _parse_integer() take variadic arguments
vsprintf: Convert to use _parse_integer() instead of
_parse_integer_limit()

 lib/kstrtox.c  |  6 ------
 lib/kstrtox.h  | 12 +++++++++++-
 lib/vsprintf.c |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)
Signature · 1 line
2.50.1