aboutsummaryrefslogtreecommitdiff
path: root/lib/string.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-08-08 21:38:05 -0400
committerTom Rini <trini@konsulko.com>2023-08-08 21:38:05 -0400
commit1e1437d9f8b5be362afdd0212dbae6c41f53f3d8 (patch)
tree7c22536424032112c0c5e3ddce45f0333478f355 /lib/string.c
parenta169438411f9277cc689c14078151aa1d1caae3c (diff)
parent70fdcc704a978acb4de5e891469825596c0d292e (diff)
downloadu-boot-1e1437d9f8b5be362afdd0212dbae6c41f53f3d8.zip
u-boot-1e1437d9f8b5be362afdd0212dbae6c41f53f3d8.tar.gz
u-boot-1e1437d9f8b5be362afdd0212dbae6c41f53f3d8.tar.bz2
Merge branch '2023-08-08-assorted-code-corrections' into next
- A number of code corrections caught by Smatch and a few others as well.
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/string.c b/lib/string.c
index ecea755..f2c6147 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -116,20 +116,18 @@ char * strncpy(char * dest,const char *src,size_t count)
* of course, the buffer size is zero). It does not pad
* out the result like strncpy() does.
*
- * Return: the number of bytes copied
+ * Return: strlen(src)
*/
size_t strlcpy(char *dest, const char *src, size_t size)
{
- if (size) {
- size_t srclen = strlen(src);
- size_t len = (srclen >= size) ? size - 1 : srclen;
+ size_t ret = strlen(src);
+ if (size) {
+ size_t len = (ret >= size) ? size - 1 : ret;
memcpy(dest, src, len);
dest[len] = '\0';
- return len + 1;
}
-
- return 0;
+ return ret;
}
#endif
@@ -191,6 +189,8 @@ char * strncat(char *dest, const char *src, size_t count)
* Compatible with *BSD: the result is always a valid NUL-terminated string that
* fits in the buffer (unless, of course, the buffer size is zero). It does not
* write past @size like strncat() does.
+ *
+ * Return: min(strlen(dest), size) + strlen(src)
*/
size_t strlcat(char *dest, const char *src, size_t size)
{