]> git.itanic.dy.fi Git - rrdd/commitdiff
rrdtool.h: Constify string constants
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Mon, 4 Jun 2012 15:42:58 +0000 (18:42 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Mon, 4 Jun 2012 15:42:58 +0000 (18:42 +0300)
String constants are being stored to these fields, so they should be
constants. Relacant casts and other changes are made within all users
of these structures.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
database.h
rrdtool.c
rrdtool.h

index 0c171f074c544df0f064d5c5c4defd098a3a1324..dd458f36aac8b4f448d36f4a9fe36871becadbf8 100644 (file)
@@ -261,8 +261,8 @@ const char *systempoptions[] = {
                .timestart = "end-" #time "d",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
-               .options = (char **)&rrdname ## options,                \
-               .text = (char **)&rrdname ## text,                      \
+               .options = (const char **)&rrdname ## options,          \
+               .text = (const char **)&rrdname ## text,                \
        };                                                              \
        static struct rrd_image rrdname ## weekly = {                   \
                .image_filename = _filename "_weekly.png",              \
@@ -271,8 +271,8 @@ const char *systempoptions[] = {
                .timestart = "end-" #time "w",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
-               .options = (char **)&rrdname ## options,                \
-               .text = (char **)&rrdname ## text,                      \
+               .options = (const char **)&rrdname ## options,          \
+               .text = (const char **)&rrdname ## text,                \
        };                                                              \
        static struct rrd_image rrdname ## monthly = {                  \
                .image_filename = _filename "_monthly.png",             \
@@ -281,8 +281,8 @@ const char *systempoptions[] = {
                .timestart = "end-" #time "m",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
-               .options = (char **)&rrdname ## options,                \
-               .text = (char **)&rrdname ## text,                      \
+               .options = (const char **)&rrdname ## options,          \
+               .text = (const char **)&rrdname ## text,                \
        };                                                              \
        static struct rrd_image rrdname ## yearly = {                   \
                .image_filename = _filename "_yearly.png",              \
@@ -291,8 +291,8 @@ const char *systempoptions[] = {
                .timestart = "end-" #time "y",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
-               .options = (char **)&rrdname ## options,                \
-               .text = (char **)&rrdname ## text,                      \
+               .options = (const char **)&rrdname ## options,          \
+               .text = (const char **)&rrdname ## text,                \
        };
 
 DEFINE_IMAGE(cpu,      SYSINFO_PATH "/images/cpu", 720, 480, 1);
@@ -434,7 +434,7 @@ static struct rrd_database systemp_rrd = {
        .name           = "systemp",
 };
 
-char *network_interfaces[] = {
+const char *network_interfaces[] = {
        "eth0",
        "eth1",
        NULL,
index a7ad86ebe50dc0ac6023db38adf6141b3680927d..4a8348b3ac5f347bd7161a542ad51f5ec79f6016 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -84,7 +84,7 @@ int rrdtool_draw_image(struct rrd_image *image)
        }
 
        for (i = 0; image->text[i]; i++) {
-               args[argcnt++] = image->text[i];
+               args[argcnt++] = (char *)image->text[i];
        }
 
        add_arg(args, argcnt, argstr, idx, "COMMENT:Last update %s\\c", timestamp);
@@ -166,10 +166,10 @@ int rrdtool_update_data(struct rrd_database *rrd)
        char data[RRD_DATA_MAX_LEN + 2];
        char cmd[] = RRDTOOL_CMD;
 //     char cmd[] = "echo";
-       char *cmdline[] = {
+       char *const cmdline[] = {
                RRDTOOL_CMD,
                "update",
-               rrd->filename,
+               (char *const)rrd->filename,
                data,
                0
        };
index b45f51f531d68042957e4e7be87e3d6824d1845e..57bc6589182ecc0aebf7476c83d9a03c83751793 100644 (file)
--- a/rrdtool.h
+++ b/rrdtool.h
@@ -4,40 +4,40 @@
 #define MAX_STRLEN 16
 
 struct rrd_image {
-       char    *rrd_database;  /* Database file path */
-       char    *image_filename; /* Output image */
+       const char *rrd_database;       /* Database file path */
+       const char *image_filename; /* Output image */
        int     width;          /* Image dimensions */
        int     height;
        char    timestart[MAX_STRLEN];
        char    timeend[MAX_STRLEN];
        char    imageformat[MAX_STRLEN];
-       char    **options;      /* Null terminated list of rrdgraph options */
+       const char **options; /* Null terminated list of rrdgraph options */
        int     text_lead;      /* Number of spaces at the beginning of line */
-       char    **text;         /* Null terminated list of text lines */
+       const char      **text; /* Null terminated list of text lines */
 };
 
 struct rrd_data_source {
-       char *type;     /* Data source type, such as GAUGE or COUNTER */
-       char *name;
+       const char *type; /* Data source type, such as GAUGE or COUNTER */
+       const char *name;
        int heartbeat;  /* Heartbeat value in seconds */
        double min;     /* Maximum and minimum values accepted by data source */
        double max;
 };
 
 struct rrd_archive {
-       char *type;     /* Archive type, such as MAX, MIN or AVERAGE */
+       const char *type; /* Archive type, such as MAX, MIN or AVERAGE */
        double xff;     /* xfiles factor, 0..1 exclusive */
        int steps;      /* How many points needed to construct data point */
        int rows;       /* How many points are kept */
 };
 
 struct rrd_database {
-       char    *filename;      /* rrd database location */
+       const char *filename;   /* rrd database location */
        int     interval;       /* Update interval */
 
        /* Parser to aquire data for rrd */
        int (*parse)(char *rrd_data, void *parser_data);
-       void *parser_data;      /* data to be fed to the parser */
+       const char **parser_data;       /* data to be fed to the parser */
 
        struct  rrd_image **images; /* Images to draw */
 
@@ -45,7 +45,7 @@ struct rrd_database {
        struct rrd_archive *archives;    /* generating new rrd database */
 
        int     last_update;    /* When was the data last updated */
-       char    *name;          /* Name of the database */
+       const char *name;               /* Name of the database */
 };
 
 int rrdtool_draw_image(struct rrd_image *image);