X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetlink.c;h=b998cf316c6522b09f068a04b83cb7956c3c305f;hb=39049b56158161b4f9eeacdad8918bcf0f1f7e90;hp=0bd598cbbf29f96d83980df1f31b6982fc202a40;hpb=06a86a60a7dabc685bdbd81ce3d36ea5f7e2c2d4;p=collectd.git diff --git a/src/netlink.c b/src/netlink.c index 0bd598cb..b998cf31 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -27,8 +27,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #include @@ -198,7 +198,8 @@ static void submit_two(const char *dev, const char *type, const char *type_instance, derive_t rx, derive_t tx) { value_list_t vl = VALUE_LIST_INIT; value_t values[] = { - {.derive = rx}, {.derive = tx}, + {.derive = rx}, + {.derive = tx}, }; vl.values = values; @@ -509,8 +510,8 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { if (strcmp(tc_type, "filter") == 0) numberic_id = tm->tcm_parent; - snprintf(tc_inst, sizeof(tc_inst), "%s-%x:%x", kind, numberic_id >> 16, - numberic_id & 0x0000FFFF); + ssnprintf(tc_inst, sizeof(tc_inst), "%s-%x:%x", kind, numberic_id >> 16, + numberic_id & 0x0000FFFF); } DEBUG("netlink plugin: qos_filter_cb: got %s for %s (%i).", tc_type, dev, @@ -541,9 +542,9 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { stats_submitted = true; - int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, - tc_inst); - if (r >= sizeof(type_instance)) { + int r = ssnprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, + tc_inst); + if ((size_t)r >= sizeof(type_instance)) { ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d", sizeof(type_instance), r); return MNL_CB_ERROR; @@ -580,9 +581,9 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { if (!stats_submitted && ts != NULL) { char type_instance[DATA_MAX_NAME_LEN]; - int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, - tc_inst); - if (r >= sizeof(type_instance)) { + int r = ssnprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, + tc_inst); + if ((size_t)r >= sizeof(type_instance)) { ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d", sizeof(type_instance), r); return MNL_CB_ERROR; @@ -637,7 +638,7 @@ static int ir_config(const char *key, const char *value) { } else if ((strcasecmp(key, "QDisc") == 0) || (strcasecmp(key, "Class") == 0) || (strcasecmp(key, "Filter") == 0)) { - if ((fields_num < 1) || (fields_num > 2)) { + if (fields_num > 2) { ERROR("netlink plugin: Invalid number of fields for option " "`%s'. Got %i, expected 1 or 2.", key, fields_num);