From ce0d6380547e3028560910e1c9c8120531341ac6 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 4 Jun 2026 10:58:56 +0100 Subject: [PATCH] lib: kstrtox: Make _parse_integer() take variadic arguments Instead of having different functions that just use default parameters, combine those to use variadic arguments, so the user may call it using the same name. Signed-off-by: Andy Shevchenko Acked-by: Petr Mladek Signed-off-by: Rodrigo Alencar Signed-off-by: Jonathan Cameron --- lib/kstrtox.c | 6 ------ lib/kstrtox.h | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/kstrtox.c b/lib/kstrtox.c index edc4eb7c1bca..adc03e27e4a2 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c @@ -94,12 +94,6 @@ unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned lon return rv | overflow; } -noinline -unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p) -{ - return _parse_integer_limit(s, base, p, INT_MAX); -} - static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) { unsigned long long _res; diff --git a/lib/kstrtox.h b/lib/kstrtox.h index 158c400ca865..00cf3255bdd2 100644 --- a/lib/kstrtox.h +++ b/lib/kstrtox.h @@ -2,10 +2,17 @@ #ifndef _LIB_KSTRTOX_H #define _LIB_KSTRTOX_H +#include + #define KSTRTOX_OVERFLOW (1U << 31) const char *_parse_integer_fixup_radix(const char *s, unsigned int *base); unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *res, size_t max_chars); -unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res); + +#define _parse_integer0(s, base, res, ...) \ + _parse_integer_limit(s, base, res, INT_MAX) + +#define _parse_integer(s, base, res, ...) \ + CONCATENATE(_parse_integer, COUNT_ARGS(__VA_ARGS__))(s, base, res, __VA_ARGS__) #endif