From: Kamil Wiatrowski Date: Thu, 17 May 2018 14:15:24 +0000 (+0100) Subject: intel_pmu plugin: fix for PR comments X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=94d47feb8c5ffd017213b10206806e418a05dd7b;p=collectd.git intel_pmu plugin: fix for PR comments Check for failure from snprintf. Make cgroup and event const in pmu_submit_counter. Change-Id: I5547375da26c3a63b76588b733e844e3199e9bb8 Signed-off-by: Kamil Wiatrowski --- diff --git a/src/intel_pmu.c b/src/intel_pmu.c index 57ae9748..fc7d6804 100644 --- a/src/intel_pmu.c +++ b/src/intel_pmu.c @@ -213,8 +213,12 @@ static void pmu_dump_cgroups(void) { return; } for (size_t j = 0; j < cgroup->num_cores; j++) - snprintf(cores + strlen(cores), cores_size - strlen(cores), " %d", - cgroup->cores[j]); + if (snprintf(cores + strlen(cores), cores_size - strlen(cores), " %d", + cgroup->cores[j]) < 0) { + DEBUG(PMU_PLUGIN ": Failed to write list of cores to string."); + sfree(cores); + return; + } DEBUG(PMU_PLUGIN ": group[%" PRIsz "]", i); DEBUG(PMU_PLUGIN ": description: %s", cgroup->desc); @@ -325,8 +329,8 @@ static int pmu_config(oconfig_item_t *ci) { return 0; } -static void pmu_submit_counter(char *cgroup, char *event, counter_t value, - meta_data_t *meta) { +static void pmu_submit_counter(const char *cgroup, const char *event, + counter_t value, meta_data_t *meta) { value_list_t vl = VALUE_LIST_INIT; vl.values = &(value_t){.counter = value};