From 6f8e9c1d7e8e1fef00cbafc7eeeb750ae153d89e Mon Sep 17 00:00:00 2001 From: Serhiy Pshyk Date: Fri, 6 Oct 2017 02:24:11 +0100 Subject: [PATCH] intel_pmu: address PR comments Signed-off-by: Serhiy Pshyk --- src/intel_pmu.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/intel_pmu.c b/src/intel_pmu.c index 351f81b0..fd2bd6f3 100644 --- a/src/intel_pmu.c +++ b/src/intel_pmu.c @@ -289,18 +289,20 @@ meta_data_t *pmu_meta_data_create(const struct efd *efd) { meta_data_t *meta = NULL; /* create meta data only if value was scaled */ - if (efd->val[1] != efd->val[2] && efd->val[2]) { - meta = meta_data_create(); - if (meta == NULL) { - ERROR(PMU_PLUGIN ": meta_data_create failed."); - return NULL; - } + if (efd->val[1] == efd->val[2] || !efd->val[2]) { + return NULL; + } - meta_data_add_unsigned_int(meta, "intel_pmu:raw_count", efd->val[0]); - meta_data_add_unsigned_int(meta, "intel_pmu:time_enabled", efd->val[1]); - meta_data_add_unsigned_int(meta, "intel_pmu:time_running", efd->val[2]); + meta = meta_data_create(); + if (meta == NULL) { + ERROR(PMU_PLUGIN ": meta_data_create failed."); + return NULL; } + meta_data_add_unsigned_int(meta, "intel_pmu:raw_count", efd->val[0]); + meta_data_add_unsigned_int(meta, "intel_pmu:time_enabled", efd->val[1]); + meta_data_add_unsigned_int(meta, "intel_pmu:time_running", efd->val[2]); + return meta; } @@ -332,10 +334,7 @@ static void pmu_dispatch_data(void) { /* dispatch per CPU value */ pmu_submit_counter(i, e->event, value, meta); - if (meta) { - meta_data_destroy(meta); - meta = NULL; - } + meta_data_destroy(meta); } if (event_enabled > 0) { -- 2.11.0