If we try to compile memset.c with a C++ compiler, we get warnings on various implied pointer conversions. Let's make them explict, and this way the code can compile as either C or C++ code.
I want to be able to compile it as C++ code because in the next patch I want to use it in fastlz/lzloader.cc. Signed-off-by: Nadav Har'El <[email protected]> --- libc/string/memset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libc/string/memset.c b/libc/string/memset.c index 0d7f1c9d..c42d00cf 100644 --- a/libc/string/memset.c +++ b/libc/string/memset.c @@ -9,13 +9,13 @@ void *memset_base(void *dest, int c, size_t n) { - unsigned char *s = dest; + unsigned char *s = (unsigned char *)dest; c = (unsigned char)c; for (; ((uintptr_t)s & ALIGN) && n; n--) *s++ = c; if (n) { size_t *w, k = ONES * c; - for (w = (void *)s; n>=SS; n-=SS, w++) *w = k; - for (s = (void *)w; n; n--, s++) *s = c; + for (w = (size_t *)s; n>=SS; n-=SS, w++) *w = k; + for (s = (unsigned char *)w; n; n--, s++) *s = c; } return dest; } -- 2.26.2 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/20200523204734.71598-1-nyh%40scylladb.com.
