X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftypes_list.c;h=ed832fee0baf7721a1de9ab5610741d283882332;hb=799daf946e48c5c3b5f6b016bc9290fe562f062d;hp=ff8426286ac515472b63285aee83fe7df0d45cb7;hpb=4d36d5826a3853ccd62195daf3b831d942850f1a;p=collectd.git diff --git a/src/types_list.c b/src/types_list.c index ff842628..ed832fee 100644 --- a/src/types_list.c +++ b/src/types_list.c @@ -34,7 +34,7 @@ static int parse_ds (data_source_t *dsrc, char *buf, size_t buf_len) if (buf_len < 11) { - ERROR ("parse_ds: (buf_len = %u) < 11", buf_len); + ERROR ("parse_ds: (buf_len = %zu) < 11", buf_len); return (-1); } @@ -62,8 +62,7 @@ static int parse_ds (data_source_t *dsrc, char *buf, size_t buf_len) return (-1); } - strncpy (dsrc->name, fields[0], sizeof (dsrc->name)); - dsrc->name[sizeof (dsrc->name) - 1] = '\0'; + sstrncpy (dsrc->name, fields[0], sizeof (dsrc->name)); if (strcasecmp (fields[1], "GAUGE") == 0) dsrc->type = DS_TYPE_GAUGE; @@ -85,9 +84,6 @@ static int parse_ds (data_source_t *dsrc, char *buf, size_t buf_len) else dsrc->max = atof (fields[3]); - DEBUG ("parse_ds: dsrc = {%s, %i, %lf, %lf};", - dsrc->name, dsrc->type, dsrc->min, dsrc->max); - return (0); } /* int parse_ds */ @@ -108,8 +104,7 @@ static void parse_line (char *buf) memset (ds, '\0', sizeof (data_set_t)); - strncpy (ds->type, fields[0], sizeof (ds->type)); - ds->type[sizeof (ds->type) - 1] = '\0'; + sstrncpy (ds->type, fields[0], sizeof (ds->type)); ds->ds_num = fields_num - 1; ds->ds = (data_source_t *) calloc (ds->ds_num, sizeof (data_source_t)); @@ -125,9 +120,6 @@ static void parse_line (char *buf) return; } - DEBUG ("parse_line: ds = {%s, %i, %p};", - ds->type, ds->ds_num, (void *) ds->ds); - plugin_register_data_set (ds); sfree (ds->ds); @@ -180,7 +172,9 @@ int read_types_list (const char *file) if (fh == NULL) { char errbuf[1024]; - ERROR ("open (%s) failed: %s", + fprintf (stderr, "Failed to open types database `%s': %s.\n", + file, sstrerror (errno, errbuf, sizeof (errbuf))); + ERROR ("Failed to open types database `%s': %s", file, sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); }