Skip to contentSkip to conversation

kstrtox: make _parse_integer() flexible

PATCH In review Andy Shevchenko 4 participants 16 messages Jun 2 – Jun 4

Subsystems (2)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

cover 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
author reviewer
#1 lore raw

PATCH 1/2 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.

---
 lib/kstrtox.c | 6 ------
 lib/kstrtox.h | 9 ++++++++-
 2 files changed, 8 insertions(+), 7 deletions(-)
lib/kstrtox.c +0 -6
index edc4eb7c1bca..adc03e27e4a2 100644
@@ -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;
lib/kstrtox.h +8 -1
index 158c400ca865..6c7ca3b67429 100644
@@ -2,10 +2,17 @@
 #ifndef _LIB_KSTRTOX_H
 #define _LIB_KSTRTOX_H
 
+#include <linux/args.h>
+
 #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
Signature · 1 line
2.50.1
author reviewer
#2 lore raw

Re: [PATCH v1 1/2] kstrtox: Make _parse_integer() take variadic arguments

Quoted 3 lines · Andy Shevchenko

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.

...

Maybe we also need to add a comment here

/* Do NOT call this directly, use _parse_integer() wrapper instead */

Quoted 2 lines

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

...

Overall I think independently on the new user (if it comes or not) this change is good on itself. Petr, what do you think about this?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH v1 1/2] kstrtox: Make _parse_integer() take variadic arguments

In reply to Andy Shevchenko
Quoted 3 lines · On Tue, 2 Jun 2026 22:29:46 +0200 Andy Shevchenko…

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.

Adding a default final parameter can be done generically:

#define one(v) v
#define first(v, ...) v
#define dflt(d, ...) first(__VA_OPT__(one(__VA_ARGS__) ,) d)

int foo(int, int);
#define foo(a, ...) foo(a, dflt(42, ## __VA_ARGS__))

See: https://godbolt.org/z/x5aao7reK

-- David

Quoted 47 lines
---
 lib/kstrtox.c | 6 ------
 lib/kstrtox.h | 9 ++++++++-
 2 files changed, 8 insertions(+), 7 deletions(-)
lib/kstrtox.c +0 -6
index edc4eb7c1bca..adc03e27e4a2 100644
@@ -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;
lib/kstrtox.h +8 -1
index 158c400ca865..6c7ca3b67429 100644
@@ -2,10 +2,17 @@
 #ifndef _LIB_KSTRTOX_H
 #define _LIB_KSTRTOX_H
 
+#include <linux/args.h>
+
 #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
author reviewer
#4 lore raw

Re: [PATCH v1 1/2] kstrtox: Make _parse_integer() take variadic arguments

Quoted 8 lines · David Laight
Quoted 3 lines · On Tue, 2 Jun 2026 22:29:46 +0200 Andy Shevchenko…

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.

Adding a default final parameter can be done generically:

Only one?

Quoted 8 lines

#define one(v) v
#define first(v, ...) v
#define dflt(d, ...) first(__VA_OPT__(one(__VA_ARGS__) ,) d)

int foo(int, int);
#define foo(a, ...) foo(a, dflt(42, ## __VA_ARGS__))

See: https://godbolt.org/z/x5aao7reK

I know, we support some GCC versions that do not provide it.

551d44200152 ("default_gfp(): avoid using the "newfangled" __VA_OPT__ trick")

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#5 lore raw

Re: [PATCH v1 1/2] kstrtox: Make _parse_integer() take variadic arguments

Quoted 16 lines · Andy Shevchenko
Quoted 8 lines · David Laight
Quoted 3 lines · On Tue, 2 Jun 2026 22:29:46 +0200 Andy Shevchenko…

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.

Adding a default final parameter can be done generically:

Only one?

Quoted 4 lines

#define one(v) v
#define first(v, ...) v
#define dflt(d, ...) first(__VA_OPT__(one(__VA_ARGS__) ,) d)

Quoted 8 lines
Quoted 4 lines

int foo(int, int);
#define foo(a, ...) foo(a, dflt(42, ## __VA_ARGS__))

See: https://godbolt.org/z/x5aao7reK

I know, we support some GCC versions that do not provide it.

551d44200152 ("default_gfp(): avoid using the "newfangled" __VA_OPT__ trick")

I stand corrected, it's all about sparse. Since this is the generic header, I would also avoid using VA_OPT even if it allows more than one optional argument.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH v1 1/2] kstrtox: Make _parse_integer() take variadic arguments

Quoted 22 lines · On Wed, 3 Jun 2026 13:56:24 +0300 Andy Shevchenko…
Quoted 21 lines · Andy Shevchenko
Quoted 8 lines · David Laight
Quoted 3 lines · On Tue, 2 Jun 2026 22:29:46 +0200 Andy Shevchenko…

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.

Adding a default final parameter can be done generically:

Only one?

Quoted 8 lines

#define one(v) v
#define first(v, ...) v
#define dflt(d, ...) first(__VA_OPT__(one(__VA_ARGS__) ,) d)

int foo(int, int);
#define foo(a, ...) foo(a, dflt(42, ## __VA_ARGS__))

See: https://godbolt.org/z/x5aao7reK

Quoted 7 lines
Quoted 3 lines

I know, we support some GCC versions that do not provide it.

551d44200152 ("default_gfp(): avoid using the "newfangled" __VA_OPT__ trick")

I stand corrected, it's all about sparse. Since this is the generic header, I would also avoid using VA_OPT even if it allows more than one optional argument.

I'm not sure multiple optional arguments are overly useful. Starts getting difficult knowing what they are for.

Really the C standard should have added named parameters ages ago. Perhaps as:

	int f(int a, int b, int c = 0);
then:
	x = f(b:17, a:42);

then you could have default values for any parameters.
Would also be less error prone for functions with lots of flag parameters.

For sparse it only has to expand to valid C.
So how about something like the following for sparse builds?

#define dlft(d, ...) (one(__VA_ARGS__) + 0 ?: (d))

-- David

author reviewer
#7 lore raw

PATCH 2/2 vsprintf: Convert to use _parse_integer() instead of _parse_integer_limit()

In reply to Andy Shevchenko

Use _parse_integer() that allows optional arguments to be explicitly initialised.

---
 lib/kstrtox.h  | 3 +++
 lib/vsprintf.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
lib/kstrtox.h +3 -0
index 6c7ca3b67429..4299b1f92133 100644
@@ -12,6 +12,9 @@ unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned lon
 #define _parse_integer0(s, base, res, ...)						\
 	_parse_integer_limit(s, base, res, INT_MAX);
 
+#define _parse_integer1(s, base, res, max_chars, ...)					\
+	_parse_integer_limit(s, base, res, max_chars);
+
 #define _parse_integer(s, base, res, ...)						\
 	CONCATENATE(_parse_integer, COUNT_ARGS(__VA_ARGS__))(s, base, res, __VA_ARGS__)
 
lib/vsprintf.c +1 -1
index a3017bc58986..1389b50266bf 100644
@@ -86,7 +86,7 @@ static unsigned long long simple_strntoull(const char *startp, char **endp, unsi
 	cp = _parse_integer_fixup_radix(startp, &base);
 	prefix_chars = cp - startp;
 	if (prefix_chars < max_chars) {
-		rv = _parse_integer_limit(cp, base, &result, max_chars - prefix_chars);
+		rv = _parse_integer(cp, base, &result, max_chars - prefix_chars);
 		/* FIXME */
 		cp += (rv & ~KSTRTOX_OVERFLOW);
 	} else {
Signature · 1 line
2.50.1
maintainer
#8 lore raw
In reply to Andy Shevchenko
Quoted 12 lines · Andy Shevchenko

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,

(quoted diff) +1 -1
-                                  size_t max_chars);
+                                  size_t max_chars, $new_opt_arg);
 

Review

Quoted 10 lines
(quoted diff) +4 -2
 #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);

I guess that this is about _parse_integer_limit_init() from
https://lore.kernel.org/all/[email protected]/

I personally find

_parse_integer(*s, base. *res) _parse_integer_limit(*s, base, *res, max_chars) _parse_integer_limit_init(*s, base, init, *res, max_chars)

a bit more self-explanatory than

_parse_integer(*s, base. *res) _parse_integer(*s, base, *res, max_chars) _parse_integer(*s, base, *res, max_chars, init)

especially when the meaning of the arguments need not be obvious when the function is used in the code.

Also the macro magic increases the complexity of the code.

On the other hand, I do not have strong opinion. It is not a big deal. I am not going to block it.

Quoted 1 line

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

Best Regards,
Petr

#9 lore raw
Quoted 24 lines · Petr Mladek
Quoted 12 lines · Andy Shevchenko

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,

(quoted diff) +1 -1
-                                  size_t max_chars);
+                                  size_t max_chars, $new_opt_arg);
 

Review

Quoted 10 lines
(quoted diff) +4 -2
 #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);
Quoted 9 lines

I guess that this is about _parse_integer_limit_init() from
https://lore.kernel.org/all/[email protected]/

I personally find

_parse_integer(*s, base. *res) _parse_integer_limit(*s, base, *res, max_chars) _parse_integer_limit_init(*s, base, init, *res, max_chars)

What could also be done is having a _parse_integer_ext() that would contain all the necessary arguments (one that should be indicated not to be used) and define all the other variations as static inline functions. I suppose that combines both ideas, being a pattern that is also used elsewhere:

devm_regulator_get()
devm_regulator_get_enable()
devm_regulator_get_enable_optional()

Quoted 18 lines

a bit more self-explanatory than

_parse_integer(*s, base. *res) _parse_integer(*s, base, *res, max_chars) _parse_integer(*s, base, *res, max_chars, init)

especially when the meaning of the arguments need not be obvious when the function is used in the code.

Also the macro magic increases the complexity of the code.

On the other hand, I do not have strong opinion. It is not a big deal. I am not going to block it.

Quoted 1 line

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

Best Regards,
Petr

Signature · 3 lines
Kind regards,

Rodrigo Alencar
#10 lore raw
Quoted 41 lines · Rodrigo Alencar
Quoted 24 lines · Petr Mladek
Quoted 12 lines · Andy Shevchenko

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,

(quoted diff) +1 -1
-                                  size_t max_chars);
+                                  size_t max_chars, $new_opt_arg);
 

Review

Quoted 10 lines
(quoted diff) +4 -2
 #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);
Quoted 9 lines

I guess that this is about _parse_integer_limit_init() from
https://lore.kernel.org/all/[email protected]/

I personally find

_parse_integer(*s, base. *res) _parse_integer_limit(*s, base, *res, max_chars) _parse_integer_limit_init(*s, base, init, *res, max_chars)

What could also be done is having a _parse_integer_ext() that would contain all the necessary arguments (one that should be indicated not to be used) and define all the other variations as static inline functions. I suppose that combines both ideas, being a pattern that is also used elsewhere:

Quoted 3 lines

devm_regulator_get()
devm_regulator_get_enable()
devm_regulator_get_enable_optional()

Actually the example pattern with static inline is not this one, it is under linux/reset.h with __devm_reset_control_get().

If every one agrees I can add that to the v16 of the patch series of the PLL driver.

Signature · 3 lines
Kind regards,

Rodrigo Alencar
author reviewer
#11 lore raw
Quoted 2 lines · Rodrigo Alencar
Quoted 1 line · Rodrigo Alencar

On 26/06/03 01:23PM, Petr Mladek wrote:

...

Quoted 5 lines

Actually the example pattern with static inline is not this one, it is under linux/reset.h with __devm_reset_control_get().

If every one agrees I can add that to the v16 of the patch series of the PLL driver.

...which shows disadvantage of the naming (it grows quite rapidly towards the nonsense, like devm_reset_control_array_get_exclusive_released().

Again, that's public API and I see at least some value in that. In more closed one as we discuss in this thread that adds no value.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#12 lore raw
In reply to Rodrigo Alencar
Quoted 40 lines · Rodrigo Alencar
Quoted 24 lines · Petr Mladek
Quoted 12 lines · Andy Shevchenko

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,

(quoted diff) +1 -1
-                                  size_t max_chars);
+                                  size_t max_chars, $new_opt_arg);
 

Review

Quoted 10 lines
(quoted diff) +4 -2
 #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);
Quoted 8 lines

I guess that this is about _parse_integer_limit_init() from
https://lore.kernel.org/all/[email protected]/

I personally find

_parse_integer(*s, base. *res) _parse_integer_limit(*s, base, *res, max_chars) _parse_integer_limit_init(*s, base, init, *res, max_chars)

What could also be done is having a _parse_integer_ext() that would contain all the necessary arguments (one that should be indicated not to be used) and define all the other variations as static inline functions. I suppose that combines both ideas, being a pattern that is also used elsewhere:

Quoted 3 lines

devm_regulator_get()
devm_regulator_get_enable()
devm_regulator_get_enable_optional()

devm_regulator_get*() are public APIs and that split might make sense. The _parse_integer() is internal to printf() implementation and wrappers around it, so I don't think we should really be so picky. TL;DR: I think my approach is good enough and makes not much of turbulence here, perhaps a comment would be nice to have to explain the list of optional arguments.

Quoted 6 lines
Quoted 6 lines

a bit more self-explanatory than

_parse_integer(*s, base. *res) _parse_integer(*s, base, *res, max_chars) _parse_integer(*s, base, *res, max_chars, init)

Quoted 7 lines
Quoted 7 lines

especially when the meaning of the arguments need not be obvious when the function is used in the code.

Also the macro magic increases the complexity of the code.

On the other hand, I do not have strong opinion. It is not a big deal. I am not going to block it.

Would you give your tag in case Rodrigo wants to incorporate these into his series and go via IIO tree? (I think that these two makes sense to put into immutable branch/tag and share with the users).

Quoted 1 line
Quoted 1 line
Quoted 1 line

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

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Acked-by
#13 lore raw
Quoted 60 lines · Andy Shevchenko
Quoted 40 lines · Rodrigo Alencar
Quoted 24 lines · Petr Mladek
Quoted 12 lines · Andy Shevchenko

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,

(quoted diff) +1 -1
-                                  size_t max_chars);
+                                  size_t max_chars, $new_opt_arg);
 

Review

Quoted 10 lines
(quoted diff) +4 -2
 #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);
Quoted 8 lines

I guess that this is about _parse_integer_limit_init() from
https://lore.kernel.org/all/[email protected]/

I personally find

_parse_integer(*s, base. *res) _parse_integer_limit(*s, base, *res, max_chars) _parse_integer_limit_init(*s, base, init, *res, max_chars)

What could also be done is having a _parse_integer_ext() that would contain all the necessary arguments (one that should be indicated not to be used) and define all the other variations as static inline functions. I suppose that combines both ideas, being a pattern that is also used elsewhere:

Quoted 3 lines

devm_regulator_get()
devm_regulator_get_enable()
devm_regulator_get_enable_optional()

devm_regulator_get*() are public APIs and that split might make sense. The _parse_integer() is internal to printf() implementation and wrappers around it, so I don't think we should really be so picky. TL;DR: I think my approach is good enough and makes not much of turbulence here, perhaps a comment would be nice to have to explain the list of optional arguments.

Quoted 9 lines
Quoted 9 lines

a bit more self-explanatory than

_parse_integer(*s, base. *res) _parse_integer(*s, base, *res, max_chars) _parse_integer(*s, base, *res, max_chars, init)

especially when the meaning of the arguments need not be obvious when the function is used in the code.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

Also the macro magic increases the complexity of the code.

On the other hand, I do not have strong opinion. It is not a big deal. I am not going to block it.

Would you give your tag in case Rodrigo wants to incorporate these into his series and go via IIO tree? (I think that these two makes sense to put into immutable branch/tag and share with the users).

Feel free to use for both patches:

Best Regards,
Petr

author reviewer
#14 lore raw
Quoted 1 line · Petr Mladek

On Wed 2026-06-03 16:53:49, Andy Shevchenko wrote:

...

Quoted 3 lines

Feel free to use for both patches:

Thank you, Petr!

Rodrigo, can you incorporate this into your series, please?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#15 lore raw
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Petr Mladek

On Wed 2026-06-03 16:53:49, Andy Shevchenko wrote:

...

Quoted 7 lines
Quoted 3 lines

Feel free to use for both patches:

Thank you, Petr!

Rodrigo, can you incorporate this into your series, please?

Will do, thank you!

Signature · 3 lines
Kind regards,

Rodrigo Alencar