Re: [PATCH] tools: include: add proper strscpy() declaration

From: Maxwell Doose

Date: Wed May 06 2026 - 12:48:06 EST


On Wed, May 6, 2026 at 11:34 AM Lucas Poupeau <lucasp.linux@xxxxxxxxx> wrote:
>
> Remove the macro hack and add a proper implementation in tools/lib/string.c.
> This avoids unsafe strcpy usage when strscpy is expected and fixes
> potential compilation warnings regarding str_error_r.
>
> Fixes: 9e3d665 ("memblock test: fix implicit declaration of function 'strscpy'")
> Suggested-by: Maxwell Doose <m32285159@xxxxxxxxx>
> Reviewed-by: Wei Yang <richard.weiyang@xxxxxxxxx>
> Signed-off-by: Lucas Poupeau <lucasp.linux@xxxxxxxxx>
> ---
> tools/include/linux/string.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
> index 51ad3cf4fa82..d6e53109e786 100644
> --- a/tools/include/linux/string.h
> +++ b/tools/include/linux/string.h
> @@ -12,7 +12,7 @@ void argv_free(char **argv);
>
> int strtobool(const char *s, bool *res);
>
> -#define strscpy strcpy
> +ssize_t strscpy(char *dest, const char *src, size_t count);
>
> /*
> * glibc based builds needs the extern while uClibc doesn't.
> --
> 2.54.0
>

Should be v2; please remark and add changelog.

best regards,
max