hostname is not const, but mh_uuid() returns a const char *. Just cast away the const to silence the warning.
Signed-off-by: Russell Bryant russell@russellbryant.net --- src/lib/utilities.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lib/utilities.c b/src/lib/utilities.c index cad41eb..b1fcc67 100644 --- a/src/lib/utilities.c +++ b/src/lib/utilities.c @@ -348,7 +348,7 @@ mh_hostname(void)
if(hostname != NULL && strcmp(hostname, "localhost") == 0) { free(hostname); - hostname = mh_uuid(); + hostname = (char *) mh_uuid(); }
mh_trace("Got hostname: %s", hostname);
ooo, that looks dodgy. casting away (const) isn't a good practice. We should be making a strcpy() of it instead.
On Sun, May 1, 2011 at 3:08 PM, Russell Bryant russell@russellbryant.net wrote:
hostname is not const, but mh_uuid() returns a const char *. Just cast away the const to silence the warning.
Signed-off-by: Russell Bryant russell@russellbryant.net
src/lib/utilities.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lib/utilities.c b/src/lib/utilities.c index cad41eb..b1fcc67 100644 --- a/src/lib/utilities.c +++ b/src/lib/utilities.c @@ -348,7 +348,7 @@ mh_hostname(void)
if(hostname != NULL && strcmp(hostname, "localhost") == 0) { free(hostname);
- hostname = mh_uuid();
- hostname = (char *) mh_uuid();
}
mh_trace("Got hostname: %s", hostname);
1.7.4.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
hostname is not const, but mh_uuid() returns a const char *. strdup() it to make things happy again.
Signed-off-by: Russell Bryant russell@russellbryant.net --- src/lib/utilities.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lib/utilities.c b/src/lib/utilities.c index cad41eb..1151c00 100644 --- a/src/lib/utilities.c +++ b/src/lib/utilities.c @@ -348,7 +348,7 @@ mh_hostname(void)
if(hostname != NULL && strcmp(hostname, "localhost") == 0) { free(hostname); - hostname = mh_uuid(); + hostname = strdup(mh_uuid()); }
mh_trace("Got hostname: %s", hostname);
ack
On Sun, May 1, 2011 at 3:43 PM, Russell Bryant russell@russellbryant.net wrote:
hostname is not const, but mh_uuid() returns a const char *. strdup() it to make things happy again.
Signed-off-by: Russell Bryant russell@russellbryant.net
src/lib/utilities.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lib/utilities.c b/src/lib/utilities.c index cad41eb..1151c00 100644 --- a/src/lib/utilities.c +++ b/src/lib/utilities.c @@ -348,7 +348,7 @@ mh_hostname(void)
if(hostname != NULL && strcmp(hostname, "localhost") == 0) { free(hostname);
- hostname = mh_uuid();
- hostname = strdup(mh_uuid());
}
mh_trace("Got hostname: %s", hostname);
1.7.4.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
On Mon, May 2, 2011 at 1:45 PM, Andrew Beekhof andrew@beekhof.net wrote:
ooo, that looks dodgy. casting away (const) isn't a good practice. We should be making a strcpy() of it instead.
True. I'll fix that up. I'm having deja vu. I think we've had this discussion once before about this same warning. :-)
matahari@lists.fedorahosted.org