public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Lucas Poupeau <lucasp.linux@gmail.com>
Cc: m32285159@gmail.com, richard.weiyang@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools: include: add proper strscpy() declaration
Date: Thu, 7 May 2026 02:42:09 +0000	[thread overview]
Message-ID: <20260507024209.c43ad4pazkh6fzz7@master> (raw)
In-Reply-To: <20260506163452.53067-1-lucasp.linux@gmail.com>

On Wed, May 06, 2026 at 06:34:52PM +0200, Lucas Poupeau 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'")

The Fixes tag seems not necessary.

>Suggested-by: Maxwell Doose <m32285159@gmail.com>
>Reviewed-by: Wei Yang <richard.weiyang@gmail.com>

Hmm... I didn't see your change before, so I can't reviewed yet.

It is not proper to add RB by yourself.

>Signed-off-by: Lucas Poupeau <lucasp.linux@gmail.com>
>---
> 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);
> 

You mean add proper implementation, but this is just a declaration.
Where is the definition in tools/lib/string.c? Something is missed?

After applying your patch, I got this when build tools/testing/memblock.


memblock.c: In function ‘reserved_mem_add’:
memblock.c:2464:9: error: too few arguments to function ‘strscpy’
 2464 |         strscpy(map->name, name);
      |         ^~~~~~~
In file included from ./linux/kernel.h:11,
                 from memblock.c:9:
../../include/linux/string.h:16:9: note: declared here
   16 | ssize_t strscpy(char *dest, const char *src, size_t count);
      |         ^~~~~~~
make: *** [<builtin>: memblock.o] Error 1

> /*
>  * glibc based builds needs the extern while uClibc doesn't.
>-- 
>2.54.0

-- 
Wei Yang
Help you, Help me

  parent reply	other threads:[~2026-05-07  2:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 16:34 [PATCH] tools: include: add proper strscpy() declaration Lucas Poupeau
2026-05-06 16:47 ` Maxwell Doose
2026-05-07  2:42 ` Wei Yang [this message]
2026-05-07  3:11   ` Maxwell Doose
  -- strict thread matches above, loose matches on Subject: below --
2026-05-04 21:23 Lucas Poupeau
2026-05-04 21:38 ` Maxwell Doose
2026-05-04 21:47   ` Maxwell Doose
2026-05-06  4:21     ` Maxwell Doose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260507024209.c43ad4pazkh6fzz7@master \
    --to=richard.weiyang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucasp.linux@gmail.com \
    --cc=m32285159@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox