X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgraph_def.c;h=b3589059a5b3b57f6bb24c436152f0356e4563fc;hb=57eb6f6ab2380fcee5ed6f8bc904e89dc7d22a9d;hp=1f78dddf90e16c79f3f3785d8774d9a3f80c5e81;hpb=1c73ff974cb2a94f83ae1869f8267def13742bd8;p=collection4.git diff --git a/src/graph_def.c b/src/graph_def.c index 1f78ddd..b358905 100644 --- a/src/graph_def.c +++ b/src/graph_def.c @@ -158,15 +158,22 @@ graph_def_t *def_create (graph_config_t *cfg, graph_ident_t *ident, /* {{{ */ graph_def_t *ret; if ((cfg == NULL) || (ident == NULL) || (ds_name == NULL)) + { + fprintf (stderr, "def_create: An argument is NULL\n"); return (NULL); + } selector = graph_get_selector (cfg); if (selector == NULL) + { + fprintf (stderr, "def_create: graph_get_selector failed\n"); return (NULL); + } ret = malloc (sizeof (*ret)); if (ret == NULL) { + fprintf (stderr, "def_create: malloc failed\n"); ident_destroy (selector); return (NULL); } @@ -177,18 +184,20 @@ graph_def_t *def_create (graph_config_t *cfg, graph_ident_t *ident, /* {{{ */ ret->ds_name = strdup (ds_name); if (ret->ds_name == NULL) { + fprintf (stderr, "def_create: Unable to copy DS name\n"); ident_destroy (selector); free (ret); return (NULL); } - ret->color = get_random_color (); + ret->color = UINT32_MAX; ret->next = NULL; ret->select = ident_copy_with_selector (selector, ident, IDENT_FLAG_REPLACE_ALL); if (ret->select == NULL) { + fprintf (stderr, "def_create: ident_copy_with_selector failed\n"); ident_destroy (selector); free (ret->ds_name); free (ret); @@ -316,6 +325,7 @@ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ int index; char draw_def[64]; char legend[256]; + uint32_t color; if ((def == NULL) || (ident == NULL) || (args == NULL)) return (EINVAL); @@ -346,6 +356,10 @@ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ } } + color = def->color; + if (color > 0x00ffffff) + color = get_random_color (); + index = args->index; args->index++; @@ -386,7 +400,7 @@ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ if (def->area) array_prepend_format (args->areas, "AREA:%s#%06"PRIx32, - draw_def, fade_color (def->color)); + draw_def, fade_color (color)); /* Graph part */ array_prepend_format (args->lines, "GPRINT:vdef_%04i_lst:%s last\\l", @@ -398,7 +412,7 @@ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ array_prepend_format (args->lines, "GPRINT:vdef_%04i_min:%s min,", index, (def->format != NULL) ? def->format : "%6.2lf"); array_prepend_format (args->lines, "LINE1:%s#%06"PRIx32":%s", - draw_def, def->color, legend); + draw_def, color, legend); free (file);