Alejandro Colomar
ce044d1791
*/: s/SNPRINTF/stprintf_a/
...
This name better reflects that it handles arrays, and doesn't shout.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-11-27 20:50:48 -06:00
Alejandro Colomar
655ffcbe1b
lib/, src/, tests/: Move x*() definitions to non-x* header files
...
Now that all of these are one-liners, they don't need a separate header
file. Compact stuff.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-10-27 14:32:06 +01:00
Alejandro Colomar
e645cc0d28
lib/string/sprintf/, tests/: xaprintf(): Reimplement in terms of exit_if_null()
...
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-10-27 14:32:06 +01:00
Evgeny Grin (Karlson2k)
eb71706b1c
*/: Fix including <config.h> as system header
...
"config.h" is a locally generated header. It must be included as
'#include "config.h"'.
It is already included correctly in some sources files. This commit
unifies the way how "config.h" is included.
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
2025-07-16 14:12:40 +02:00
Alejandro Colomar
423fd652b5
lib/string/sprintf/, tests/unit/: Transform x[v]asprintf() into x[v]aprintf()
...
Wrap [v]aprintf() instead of [v]asprintf(3).
Repurpose x[v]asprintf()'s tests to test x[v]aprintf().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
5949132308
lib/string/sprintf/: [v]aprintf(): Add functions
...
These functions are just like [v]asprintf(3), but simpler.
They return the newly allocated memory, which allows us to use the
[[gnu::malloc(free)]] attribute, which enhances static analysis.
They also omit the length, which we don't care about at all.
As a curiosity, Plan9 seems to provide this same API, under the name
smprint(3).
Link: <https://9fans.github.io/plan9port/man/man3/print.html >
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 23:25:02 -05:00
Alejandro Colomar
ba3456c9fd
lib/, src/, tests/: Use the standard countof() instead of our NITEMS()
...
countof() is the name blessed by the C Committee for ISO C2y.
Use it if available, and define it if not.
countof() will be provided by GCC 16 and Clang 21.
This is mostly a scripted change:
$ grep -rl NITEMS | xargs sed -i s/NITEMS/countof/;
Apart from the scripted changes, I've adjusted white-space alignment,
and of course the definition at "lib/sizeof.h".
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf#subsubsection.0.6.5.4.5 >
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf#section.0.7.21 >
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-06-03 09:34:55 -05:00
Alejandro Colomar
22272347b6
lib/string/sprintf/, lib/, src/, tests/: Move all sprintf(3)-like APIs to a subdirectory
...
And have a separate file for each pair of APIs.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-07-01 21:40:11 -05:00