libc: Adapt strlcpy to this codebase
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Thu, 27 Sep 2018 08:22:19 +0000 (09:22 +0100)
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Fri, 2 Nov 2018 13:41:33 +0000 (13:41 +0000)
Change-Id: I2f5f64aaf90caae936510e1179392a8835f493e0
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
include/lib/libc/string.h
lib/libc/libc.mk
lib/libc/strlcpy.c

index 3c8e3b65e2d0aed4812650dd006e7d2d11e50bec..ee6eeacef94eceed811a76bb0cc7bf5c15807b81 100644 (file)
@@ -28,5 +28,6 @@ void *memset(void *dst, int val, size_t count);
 size_t strlen(const char *s);
 size_t strnlen(const char *s, size_t maxlen);
 char *strrchr(const char *p, int ch);
+size_t strlcpy(char * dst, const char * src, size_t dsize);
 
 #endif /* STRING_H */
index daa2ec102cb86b20d1560faabbf4be2f27133ab3..1276f5c82b8bae2e9925f02beff0c81b484b22d5 100644 (file)
@@ -19,6 +19,7 @@ LIBC_SRCS     :=      $(addprefix lib/libc/,  \
                        snprintf.c                      \
                        strchr.c                        \
                        strcmp.c                        \
+                       strlcpy.c                       \
                        strlen.c                        \
                        strncmp.c                       \
                        strnlen.c                       \
index 019d2316a0469e01e842e047ff45be38164c56ff..c4f39bb9ba50b4d60531e93432edd59354373372 100644 (file)
@@ -1,6 +1,8 @@
 /*     $OpenBSD: strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $    */
 
 /*
+ * SPDX-License-Identifier: ISC
+ *
  * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
+#include <stdint.h>
 #include <string.h>
 
 /*
@@ -28,7 +27,7 @@ __FBSDID("$FreeBSD$");
  * Returns strlen(src); if retval >= dsize, truncation occurred.
  */
 size_t
-strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize)
+strlcpy(char * dst, const char * src, size_t dsize)
 {
        const char *osrc = src;
        size_t nleft = dsize;