commit:     6d6a52d90e5a16f86947fd163aac23d3b7b66f32
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr  5 17:02:56 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr  5 17:02:56 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6d6a52d9

xstrdup: avoid warning about clobbering t

When using optimisation, the compiler does something to a char pointer
it doesn't do to a void pointer, so use a couple of casts to avoid a
clobber warning.

 libq/xstrdup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libq/xstrdup.c b/libq/xstrdup.c
index 6924d21..e069c9d 100644
--- a/libq/xstrdup.c
+++ b/libq/xstrdup.c
@@ -29,16 +29,16 @@
 
 static char *xstrdup(const char *s)
 {
-       char *t;
+       void *t;
 
        if (s == NULL)
                return NULL;
 
-       t = strdup(s);
+       t = (void *)strdup(s);
        if (unlikely(t == NULL))
                err("Out of memory");
 
-       return t;
+       return (char *)t;
 }
 
 static char *xstrdup_len(const char *s, size_t *len)

Reply via email to