[CRIU] [PATCH 1/3] builtin_{memcpy, memset}: make compatible with libc

Kir Kolyshkin kir at openvz.org
Thu Nov 10 16:32:26 PST 2016


1. memcpy() last argument is size_t
2. memset() returns void *

Make our builtin_*() functions compatible.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/include/asm-generic/string.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/criu/include/asm-generic/string.h b/criu/include/asm-generic/string.h
index df53e66..1448a32 100644
--- a/criu/include/asm-generic/string.h
+++ b/criu/include/asm-generic/string.h
@@ -4,9 +4,9 @@
 #include "common/compiler.h"
 
 #ifndef HAS_BUILTIN_MEMCPY
-static always_inline void *builtin_memcpy(void *to, const void *from, unsigned int n)
+static always_inline void *builtin_memcpy(void *to, const void *from, size_t n)
 {
-	int i;
+	size_t i;
 	unsigned char *cto = to;
 	const unsigned char *cfrom = from;
 
@@ -47,13 +47,15 @@ static always_inline int builtin_strncmp(const char *cs, const char *ct, size_t
 #endif
 
 #ifndef HAS_BUILTIN_MEMSET
-static always_inline void builtin_memset(void *s, const int c, size_t count)
+static always_inline void *builtin_memset(void *s, const int c, size_t count)
 {
 	char *dest = s;
 	size_t i = 0;
 
 	while (i < count)
 		dest[i++] = (char) c;
+
+	return s;
 }
 #endif
 
-- 
2.7.4



More information about the CRIU mailing list