1 |
commit: 6d6a52d90e5a16f86947fd163aac23d3b7b66f32 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Apr 5 17:02:56 2018 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 5 17:02:56 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6d6a52d9 |
7 |
|
8 |
xstrdup: avoid warning about clobbering t |
9 |
|
10 |
When using optimisation, the compiler does something to a char pointer |
11 |
it doesn't do to a void pointer, so use a couple of casts to avoid a |
12 |
clobber warning. |
13 |
|
14 |
libq/xstrdup.c | 6 +++--- |
15 |
1 file changed, 3 insertions(+), 3 deletions(-) |
16 |
|
17 |
diff --git a/libq/xstrdup.c b/libq/xstrdup.c |
18 |
index 6924d21..e069c9d 100644 |
19 |
--- a/libq/xstrdup.c |
20 |
+++ b/libq/xstrdup.c |
21 |
@@ -29,16 +29,16 @@ |
22 |
|
23 |
static char *xstrdup(const char *s) |
24 |
{ |
25 |
- char *t; |
26 |
+ void *t; |
27 |
|
28 |
if (s == NULL) |
29 |
return NULL; |
30 |
|
31 |
- t = strdup(s); |
32 |
+ t = (void *)strdup(s); |
33 |
if (unlikely(t == NULL)) |
34 |
err("Out of memory"); |
35 |
|
36 |
- return t; |
37 |
+ return (char *)t; |
38 |
} |
39 |
|
40 |
static char *xstrdup_len(const char *s, size_t *len) |