All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Simplify implementation of strscpy()
@ 2026-11-03 13:27 Alejandro Colomar
  2026-11-03 13:27 ` [PATCH v1 1/2] args: Add DEFARG() to implement macro default arguments Alejandro Colomar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alejandro Colomar @ 2026-11-03 13:27 UTC (permalink / raw)
  To: Kees Cook, linux-hardening; +Cc: Alejandro Colomar, Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 929 bytes --]

Hi!

Here's a simpler implementation of the default arguments in strscpy(9).
It avoids having to build concatenated names, the ignored '...' in
__strscpy0, counting arguments, etc.  It's replaced by a quite simple
macro that takes two arguments, and picks the last non-empty one.

It requires a C23 feature, but it's supported as a GNU extension in
GNU C11 mode, and was implemented a long time ago, so it should be fine.


Have a lovely day!
Alex

Alejandro Colomar (2):
  args: Add DEFARG() to implement macro default arguments
  string: Simplify strscpy[_pad]()

 include/linux/args.h   |  5 +++++
 include/linux/string.h | 22 ++++------------------
 2 files changed, 9 insertions(+), 18 deletions(-)

Range-diff against v0:
-:  ------------ > 1:  be1057524eb2 args: Add DEFARG() to implement macro default arguments
-:  ------------ > 2:  31096484d9be string: Simplify strscpy[_pad]()
-- 
2.55.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-03 23:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 13:27 [PATCH v1 0/2] Simplify implementation of strscpy() Alejandro Colomar
2026-11-03 13:27 ` [PATCH v1 1/2] args: Add DEFARG() to implement macro default arguments Alejandro Colomar
2026-11-03 13:31   ` Alejandro Colomar
2026-11-03 13:27 ` [PATCH v1 2/2] string: Simplify strscpy[_pad]() Alejandro Colomar
2026-11-03 19:10 ` [PATCH v1 0/2] Simplify implementation of strscpy() Andy Shevchenko
2026-11-03 23:21   ` Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.