From: Ruben Kerkhof Date: Sun, 16 Jul 2017 20:33:21 +0000 (+0200) Subject: Merge branch 'ssnprintf-cleanup' X-Git-Tag: collectd-5.8.0~118 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7f38ca96e3a54a4b02475f857c7d79c6a1257ada;p=collectd.git Merge branch 'ssnprintf-cleanup' Conflicts: src/dpdkevents.c src/utils_dpdk.c src/write_mongodb.c --- 7f38ca96e3a54a4b02475f857c7d79c6a1257ada diff --cc src/utils_dpdk.c index 4f9243ea,4b246c9e..77f596eb --- a/src/utils_dpdk.c +++ b/src/utils_dpdk.c @@@ -103,10 -103,11 +103,10 @@@ static void dpdk_helper_config_default( DPDK_HELPER_TRACE(phc->shm_name); - ssnprintf(phc->eal_config.coremask, DATA_MAX_NAME_LEN, "%s", "0xf"); - ssnprintf(phc->eal_config.memory_channels, DATA_MAX_NAME_LEN, "%s", "1"); - ssnprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, "%s", - DPDK_DEFAULT_RTE_CONFIG); + snprintf(phc->eal_config.coremask, DATA_MAX_NAME_LEN, "%s", "0xf"); + snprintf(phc->eal_config.memory_channels, DATA_MAX_NAME_LEN, "%s", "1"); - snprintf(phc->eal_config.process_type, DATA_MAX_NAME_LEN, "%s", "secondary"); + snprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, "%s", + DPDK_DEFAULT_RTE_CONFIG); } int dpdk_helper_eal_config_set(dpdk_helper_ctx_t *phc, dpdk_eal_config_t *ec) { @@@ -176,15 -176,15 +176,15 @@@ int dpdk_helper_eal_config_parse(dpdk_h status = cf_util_get_string_buffer(child, phc->eal_config.socket_memory, sizeof(phc->eal_config.socket_memory)); DEBUG("dpdk_common: EAL:Socket memory %s", phc->eal_config.socket_memory); - } else if (strcasecmp("ProcessType", child->key) == 0) { - status = cf_util_get_string_buffer(child, phc->eal_config.process_type, - sizeof(phc->eal_config.process_type)); - DEBUG("dpdk_common: EAL:Process type %s", phc->eal_config.process_type); - } else if ((strcasecmp("FilePrefix", child->key) == 0) && - (child->values[0].type == OCONFIG_TYPE_STRING)) { - snprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, - "/var/run/.%s_config", child->values[0].value.string); - DEBUG("dpdk_common: EAL:File prefix %s", phc->eal_config.file_prefix); + } else if (strcasecmp("FilePrefix", child->key) == 0) { + char prefix[DATA_MAX_NAME_LEN]; + + status = cf_util_get_string_buffer(child, prefix, sizeof(prefix)); + if (status == 0) { - ssnprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, ++ snprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, + "/var/run/.%s_config", prefix); + DEBUG("dpdk_common: EAL:File prefix %s", phc->eal_config.file_prefix); + } } else { ERROR("dpdk_common: Invalid '%s' configuration option", child->key); status = -EINVAL; diff --cc src/write_mongodb.c index e1fb41fd,37e34098..46b6d865 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@@ -93,10 -93,10 +93,10 @@@ static bson_t *wm_create_bson(const dat BSON_APPEND_UTF8(ret, "type_instance", vl->type_instance); BSON_APPEND_ARRAY_BEGIN(ret, "values", &subarray); /* {{{ */ - for (int i = 0; i < ds->ds_num; i++) { + for (size_t i = 0; i < ds->ds_num; i++) { char key[16]; - ssnprintf(key, sizeof(key), "%zu", i); - snprintf(key, sizeof(key), "%i", i); ++ snprintf(key, sizeof(key), "%zu", i); if (ds->ds[i].type == DS_TYPE_GAUGE) BSON_APPEND_DOUBLE(&subarray, key, vl->values[i].gauge); @@@ -118,10 -118,10 +118,10 @@@ bson_append_array_end(ret, &subarray); /* }}} values */ BSON_APPEND_ARRAY_BEGIN(ret, "dstypes", &subarray); /* {{{ */ - for (int i = 0; i < ds->ds_num; i++) { + for (size_t i = 0; i < ds->ds_num; i++) { char key[16]; - ssnprintf(key, sizeof(key), "%zu", i); - snprintf(key, sizeof(key), "%i", i); ++ snprintf(key, sizeof(key), "%zu", i); if (store_rates) BSON_APPEND_UTF8(&subarray, key, "gauge"); @@@ -131,10 -131,10 +131,10 @@@ bson_append_array_end(ret, &subarray); /* }}} dstypes */ BSON_APPEND_ARRAY_BEGIN(ret, "dsnames", &subarray); /* {{{ */ - for (int i = 0; i < ds->ds_num; i++) { + for (size_t i = 0; i < ds->ds_num; i++) { char key[16]; - ssnprintf(key, sizeof(key), "%zu", i); - snprintf(key, sizeof(key), "%i", i); ++ snprintf(key, sizeof(key), "%zu", i); BSON_APPEND_UTF8(&subarray, key, ds->ds[i].name); } bson_append_array_end(ret, &subarray); /* }}} dsnames */