projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mysql plugin: Fix typo in documentation
[collectd.git]
/
src
/
daemon
/
types_list.c
diff --git
a/src/daemon/types_list.c
b/src/daemon/types_list.c
index
89a08dd
..
7eb3cb2
100644
(file)
--- a/
src/daemon/types_list.c
+++ b/
src/daemon/types_list.c
@@
-26,7
+26,7
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
+#include "
utils/common/
common.h"
#include "configfile.h"
#include "plugin.h"
#include "configfile.h"
#include "plugin.h"
@@
-39,7
+39,7
@@
static int parse_ds(data_source_t *dsrc, char *buf, size_t buf_len) {
int fields_num;
if (buf_len < 11) {
int fields_num;
if (buf_len < 11) {
- ERROR("parse_ds: (buf_len = %
zu
) < 11", buf_len);
+ ERROR("parse_ds: (buf_len = %
" PRIsz "
) < 11", buf_len);
return -1;
}
return -1;
}
@@
-96,8
+96,6
@@
static int parse_ds(data_source_t *dsrc, char *buf, size_t buf_len) {
static void parse_line(char *buf) {
char *fields[64];
size_t fields_num;
static void parse_line(char *buf) {
char *fields[64];
size_t fields_num;
- data_set_t *ds;
-
fields_num = strsplit(buf, fields, 64);
if (fields_num < 2)
return;
fields_num = strsplit(buf, fields, 64);
if (fields_num < 2)
return;
@@
-106,33
+104,27
@@
static void parse_line(char *buf) {
if (fields[0][0] == '#')
return;
if (fields[0][0] == '#')
return;
- ds = calloc(1, sizeof(*ds));
- if (ds == NULL)
- return;
+ data_set_t ds = {{0}};
- sstrncpy(ds
->type, fields[0], sizeof(ds->
type));
+ 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));
- if (ds->ds == NULL) {
- sfree(ds);
+ ds.ds_num = fields_num - 1;
+ ds.ds = calloc(ds.ds_num, sizeof(*ds.ds));
+ if (ds.ds == NULL)
return;
return;
- }
- for (size_t i = 0; i < ds->ds_num; i++)
- if (parse_ds(ds->ds + i, fields[i + 1], strlen(fields[i + 1])) != 0) {
- ERROR("types_list: parse_line: Cannot parse data source #%zu "
- "of data set %s",
- i, ds->type);
- sfree(ds->ds);
- sfree(ds);
+ for (size_t i = 0; i < ds.ds_num; i++)
+ if (parse_ds(ds.ds + i, fields[i + 1], strlen(fields[i + 1])) != 0) {
+ ERROR("types_list: parse_line: Cannot parse data source #%" PRIsz
+ " of data set %s",
+ i, ds.type);
+ sfree(ds.ds);
return;
}
return;
}
- plugin_register_data_set(ds);
+ plugin_register_data_set(
&
ds);
- sfree(ds->ds);
- sfree(ds);
+ sfree(ds.ds);
} /* void parse_line */
static void parse_file(FILE *fh) {
} /* void parse_line */
static void parse_file(FILE *fh) {
@@
-174,11
+166,9
@@
int read_types_list(const char *file) {
fh = fopen(file, "r");
if (fh == NULL) {
fh = fopen(file, "r");
if (fh == NULL) {
- char errbuf[1024];
fprintf(stderr, "Failed to open types database `%s': %s.\n", file,
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)));
+ STRERRNO);
+ ERROR("Failed to open types database `%s': %s", file, STRERRNO);
return -1;
}
return -1;
}