Re: [RFC] string: Allow 2-argument strscpy()

From: Andy Shevchenko
Date: Mon Jan 29 2024 - 18:29:50 EST


On Tue, Jan 30, 2024 at 12:03 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> On Mon, Jan 29, 2024 at 09:55:25PM +0000, Justin Stitt wrote:
> > On Mon, Jan 29, 2024 at 12:29:04PM -0800, Kees Cook wrote:

..

> > BTW, this hack for function overloading is insane. Never really looked into
> > it before.
>
> It very much is. :P Hence the RFC nature of this patch. I don't think we
> any any other API in the kernel that does this (though there are plenty
> of wild macro wrappers to do similar tricks, like the syscall wrappers).

PCI has a couple of such.

> > I like this, though, should you include documentation changes/additions?
>
> Yeah, though I'm not sure how to do this -- kerndoc expects a fixed
> number of arguments. :P Maybe I can just do something like add
> "optional" to @size:

Use ... See again PCI header (pci.h). One of the macros there has a
valid kernel-doc.

> * strscpy - Copy a C-string into a sized buffer
> * @p: Where to copy the string to
> * @q: Where to copy the string from
> * @size: Size of destination buffer (optional)


--
With Best Regards,
Andy Shevchenko