Skip to content

Simplify implementation of strscpy()

Alejandro Colomar linux-hardening linux-sparse 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2args: Add DEFARG() to implement macro default argumentsinclude/linux/args.h+5 -01 reply
2/2string: Simplify strscpy[_pad]()include/linux/string.h+4 -180 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/2] Simplify implementation of strscpy()

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]()
Signature · 1 line
2.55.0