* [PATCH] set initial length of string to 0 instead of 64
@ 2025-10-21 17:21 Biancaa Ramesh
2025-10-22 9:05 ` David Laight
0 siblings, 1 reply; 2+ messages in thread
From: Biancaa Ramesh @ 2025-10-21 17:21 UTC (permalink / raw)
To: linux-kernel; +Cc: Biancaa Ramesh
Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.edu.in>
---
scripts/kconfig/util.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 176ec03bb3f0..f55e3ce496e1 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -64,13 +64,14 @@ const char *file_lookup(const char *name)
struct gstr str_new(void)
{
struct gstr gs;
- gs.s = xmalloc(sizeof(char) * 64);
- gs.len = 64;
+ gs.s = xmalloc(64); // allocate buffer
+ gs.len = 0; // string is empty
gs.max_width = 0;
- strscpy(gs.s, "\0");
+ gs.s[0] = '\0'; // initialize as empty string
return gs;
}
+
/* Free storage for growable string */
void str_free(struct gstr *gs)
{
--
2.43.0
--
::DISCLAIMER::
---------------------------------------------------------------------
The
contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only. Views or opinions, if any,
presented in
this email are solely those of the author and may not
necessarily reflect
the views or opinions of SSN Institutions (SSN) or its
affiliates. Any form
of reproduction, dissemination, copying, disclosure,
modification,
distribution and / or publication of this message without the
prior written
consent of authorized representative of SSN is strictly
prohibited. If you
have received this email in error please delete it and
notify the sender
immediately.
---------------------------------------------------------------------
Header of this mail should have a valid DKIM signature for the domain
ssn.edu.in <http://www.ssn.edu.in/>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] set initial length of string to 0 instead of 64
2025-10-21 17:21 [PATCH] set initial length of string to 0 instead of 64 Biancaa Ramesh
@ 2025-10-22 9:05 ` David Laight
0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2025-10-22 9:05 UTC (permalink / raw)
To: Biancaa Ramesh; +Cc: linux-kernel
On Tue, 21 Oct 2025 22:51:59 +0530
Biancaa Ramesh <biancaa2210329@ssn.edu.in> wrote:
Nak
> Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.edu.in>
> ---
> scripts/kconfig/util.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
> index 176ec03bb3f0..f55e3ce496e1 100644
> --- a/scripts/kconfig/util.c
> +++ b/scripts/kconfig/util.c
> @@ -64,13 +64,14 @@ const char *file_lookup(const char *name)
> struct gstr str_new(void)
> {
> struct gstr gs;
> - gs.s = xmalloc(sizeof(char) * 64);
> - gs.len = 64;
> + gs.s = xmalloc(64); // allocate buffer
That is 'no-change'.
> + gs.len = 0; // string is empty
I'm pretty sure gs.len is the size of the buffer, so should be 64.
> gs.max_width = 0;
> - strscpy(gs.s, "\0");
Where did that strscpy() come from, it is wrong and shouldn't compile.
> + gs.s[0] = '\0'; // initialize as empty string
Equivalent to the strcpy() in 6.18-rc2.
> return gs;
> }
>
> +
> /* Free storage for growable string */
> void str_free(struct gstr *gs)
> {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-22 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 17:21 [PATCH] set initial length of string to 0 instead of 64 Biancaa Ramesh
2025-10-22 9:05 ` David Laight
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.