<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/lib/string.c, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/u-boot.git/atom/lib/string.c?h=main</id>
<link rel='self' href='http://cgit.235523.xyz/u-boot.git/atom/lib/string.c?h=main'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<updated>2026-05-12T21:41:52Z</updated>
<entry>
<title>Merge patch series "add memdup_nul(), use it and memdup() in a few places"</title>
<updated>2026-05-12T21:41:52Z</updated>
<author>
<name>Tom Rini</name>
<email>trini@konsulko.com</email>
</author>
<published>2026-05-12T21:41:52Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=e3e651c480c46b332f16a7555b97c6c6fd640a40'/>
<id>urn:sha1:e3e651c480c46b332f16a7555b97c6c6fd640a40</id>
<content type='text'>
Rasmus Villemoes &lt;ravi@prevas.dk&gt; says:

There are quite a few places where we allocate X+1 bytes, initialize
the first X bytes via memcpy() and then set the last byte to 0.

The kernel has a helper for that, kmemdup_nul(). Introduce a similar
one, and start making use of it in a few places. Also the existing
memdup() helper can be put to more use.

There are lots more places one could modify. But for code shared with
host tools, one would need to do some refactoring, putting memdup()
and memdup_nul() in their own str-util.c TU which could then also be
included in the tools build.

Link: https://lore.kernel.org/r/20260421075439.16696-1-ravi@prevas.dk
</content>
</entry>
<entry>
<title>lib/string.c: implement strdup() and strndup() in terms of memdup_nul()</title>
<updated>2026-05-12T21:38:00Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>ravi@prevas.dk</email>
</author>
<published>2026-04-21T07:54:35Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=ee8be5d4a1035de232b3497563fe9f6773775f96'/>
<id>urn:sha1:ee8be5d4a1035de232b3497563fe9f6773775f96</id>
<content type='text'>
With the addition of memdup_nul(), strdup() and strndup() can be
implemented as one-liners.

While not required by POSIX or C, do keep the behaviour of gracefully
accepting a NULL source and simply return NULL.

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Rasmus Villemoes &lt;ravi@prevas.dk&gt;
</content>
</entry>
<entry>
<title>lib/string.c: introduce memdup_nul() helper</title>
<updated>2026-05-12T21:38:00Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>ravi@prevas.dk</email>
</author>
<published>2026-04-21T07:54:34Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=8c664d2135723a110a60b792a8614c4864ad82a3'/>
<id>urn:sha1:8c664d2135723a110a60b792a8614c4864ad82a3</id>
<content type='text'>
This is completely analogous to the linux kernel's kmemdup_nul()
helper, apart from the lack of the gfp_t argument: Allocate a buffer
of size {len}+1, copy {len} bytes from the given buffer, and add a
final nul byte.

This pattern exists in a number of places, so this helper can reduce
some boilerplate code.

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Rasmus Villemoes &lt;ravi@prevas.dk&gt;
</content>
</entry>
<entry>
<title>lib/string.c: drop pointless __HAVE_ARCH_STRDUP</title>
<updated>2026-05-12T21:38:00Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>ravi@prevas.dk</email>
</author>
<published>2026-04-21T07:54:33Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=349d148f16d83da3b1e3475be0e43bfda4f4ab71'/>
<id>urn:sha1:349d148f16d83da3b1e3475be0e43bfda4f4ab71</id>
<content type='text'>
There has never been an arch-specific optimized implementation of
str[n]dup, nor is there likely to ever be one, because unlike their
cousins strlen(), strcpy() and similar that simply read/write the
src/dst, the dup functions by definition involve memory allocation. So
drop this irrelevant cpp guard.

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Rasmus Villemoes &lt;ravi@prevas.dk&gt;
</content>
</entry>
<entry>
<title>string: fix prototype of memdup()</title>
<updated>2026-05-12T21:38:00Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>ravi@prevas.dk</email>
</author>
<published>2026-04-21T07:54:31Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=ca1c292d2ee6bcb06be71400d25ae37e9dc2c1aa'/>
<id>urn:sha1:ca1c292d2ee6bcb06be71400d25ae37e9dc2c1aa</id>
<content type='text'>
It doesn't make sense to restrict memdup() to only return char*
pointers, especially when it is already defined to accept void*. This
makes it uglier to use to e.g. duplicate a struct.

Make it return void*, just as kmemdup() does in the kernel (and which
our kmemdup() in fact also does).

While in here, make a small optimization: memcpy() is defined to
return the destination register, so we write this in a way that the
compiler may do a tail call.

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Rasmus Villemoes &lt;ravi@prevas.dk&gt;
</content>
</entry>
<entry>
<title>string: add strdup_const and kstrdup_const</title>
<updated>2026-04-21T17:19:49Z</updated>
<author>
<name>Casey Connolly</name>
<email>casey.connolly@linaro.org</email>
</author>
<published>2026-04-01T14:15:19Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=139f5292e7985d0326a1d18eee88720255e423dc'/>
<id>urn:sha1:139f5292e7985d0326a1d18eee88720255e423dc</id>
<content type='text'>
Extend Linux compat by adding kstrdup_const(), backed by lib/string.c.
This leverages U-Boots .rodata section on ARM64 to avoid pointlessly
duplicating const strings.

This is used by the Linux CCF_FULL port and may be useful elsewhere
in U-Boot.

Signed-off-by: Casey Connolly &lt;casey.connolly@linaro.org&gt;
</content>
</entry>
<entry>
<title>lib: implement strnstr()</title>
<updated>2025-02-12T18:37:12Z</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>heinrich.schuchardt@canonical.com</email>
</author>
<published>2025-02-03T09:12:00Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=7c7361b98d6eadcbcde556763b6d40a686f4bd3d'/>
<id>urn:sha1:7c7361b98d6eadcbcde556763b6d40a686f4bd3d</id>
<content type='text'>
Implement library function strnstr().
Implement strstr() using strnstr().
Sort the includes.

Signed-off-by: Heinrich Schuchardt &lt;heinrich.schuchardt@canonical.com&gt;
Reviewed-by: Ilias Apalodimas &lt;ilias.apalodimas@linaro.org&gt;
[jf: replace &lt;stdint.h&gt; by &lt;limits.h&gt;, folded from next patch]
Signed-off-by: Jerome Forissier &lt;jerome.forissier@linaro.org&gt;
</content>
</entry>
<entry>
<title>lib: Mark memcpy() and memmove() as relocation code</title>
<updated>2025-02-03T22:01:36Z</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2025-01-26T18:43:23Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=4ca29703906ec28814a6fc09088ca4b01e4f94ca'/>
<id>urn:sha1:4ca29703906ec28814a6fc09088ca4b01e4f94ca</id>
<content type='text'>
Mark these functions as needed by relocation. These functions are used
to copy data while relocating the next-phase image.

Drop the 'safe' versions from SPL as they are not needed. Change the
static array to a local one, to avoid link errors when trying to access
the data.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
</entry>
<entry>
<title>lib: Remove duplicate newlines</title>
<updated>2024-07-15T18:12:18Z</updated>
<author>
<name>Marek Vasut</name>
<email>marek.vasut+renesas@mailbox.org</email>
</author>
<published>2024-07-13T13:19:22Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=2f8c004a5ae51b9b88479f3a728c564c021f50c5'/>
<id>urn:sha1:2f8c004a5ae51b9b88479f3a728c564c021f50c5</id>
<content type='text'>
Drop all duplicate newlines. No functional change.

Signed-off-by: Marek Vasut &lt;marek.vasut+renesas@mailbox.org&gt;
</content>
</entry>
<entry>
<title>Revert "lib: string: Fix strlcpy return value", fix callers</title>
<updated>2023-08-08T21:05:43Z</updated>
<author>
<name>Matthias Schiffer</name>
<email>matthias.schiffer@ew.tq-group.com</email>
</author>
<published>2023-07-14T11:24:50Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=615828721abfe8c73b5103d4436402ecbf9b9897'/>
<id>urn:sha1:615828721abfe8c73b5103d4436402ecbf9b9897</id>
<content type='text'>
Both the Linux kernel and libbsd agree that strlcpy() should always
return strlen(src) and not include the NUL termination. The incorrect
U-Boot implementation makes it impossible to check the return value for
truncation, and breaks code written with the usual implementation in
mind (for example, fdtdec_add_reserved_memory() was subtly broken).

I reviewed all callers of strlcpy() and strlcat() and fixed them
according to my understanding of the intended function.

This reverts commit d3358ecc54be0bc3b4dd11f7a63eab0a2842f772 and adds
related fixes.

Fixes: d3358ecc54be ("lib: string: Fix strlcpy return value")
Signed-off-by: Matthias Schiffer &lt;matthias.schiffer@ew.tq-group.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Reviewed-by: Sean Anderson &lt;sean.anderson@seco.com&gt;
</content>
</entry>
</feed>
