From 60a77a6f3855f181e723aa3f4f645ea480ddd359 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 7 Nov 2008 19:49:52 +0100 Subject: [PATCH] src/utils_rrdcreate.c: srrd_create: Copy the `filename' argument. Some versions of librrd, for example the one in Debian Etch, don't have the `const' qualifier for the first (filename) argument for `rrd_create_r'. So we'll copy the argument first. This sucks big time, but is the only reasonable way to get around this. --- src/utils_rrdcreate.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c index 99feda25..8ff025bd 100644 --- a/src/utils_rrdcreate.c +++ b/src/utils_rrdcreate.c @@ -253,11 +253,26 @@ static int srrd_create (const char *filename, /* {{{ */ int argc, const char **argv) { int status; + char *filename_copy; + + if ((filename == NULL) || (argv == NULL)) + return (-EINVAL); + + /* Some versions of librrd don't have the `const' qualifier for the first + * argument, so we have to copy the pointer here to avoid warnings. It sucks, + * but what else can we do? :( -octo */ + filename_copy = strdup (filename); + if (filename_copy == NULL) + { + ERROR ("srrd_create: strdup failed."); + return (-ENOMEM); + } optind = 0; /* bug in librrd? */ rrd_clear_error (); - status = rrd_create_r (filename, pdp_step, last_up, argc, (void *) argv); + status = rrd_create_r (filename_copy, pdp_step, last_up, + argc, (void *) argv); if (status != 0) { @@ -265,6 +280,8 @@ static int srrd_create (const char *filename, /* {{{ */ filename, rrd_get_error ()); } + sfree (filename_copy); + return (status); } /* }}} int srrd_create */ /* #endif HAVE_THREADSAFE_LIBRRD */ -- 2.11.0