From 49c6892bbf13cc546f60310f7550b896b5921f61 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Tue, 29 May 2018 16:36:44 +0200 Subject: [PATCH] intel_rdt: fix a bunch of warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit CC src/intel_rdt_la-intel_rdt.lo src/intel_rdt.c: In function ‘rdt_is_core_id_valid’: src/intel_rdt.c:163:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare] for (int i = 0; i < g_rdt->pqos_cpu->num_cores; i++) ^ src/intel_rdt.c:164:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare] if (core_id == g_rdt->pqos_cpu->cores[i].lcore) ^~ src/intel_rdt.c: In function ‘rdt_config_cgroups’: src/intel_rdt.c:208:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare] for (int i = 0; i < g_rdt->cap_mon->u.mon->num_events; i++) ^ src/intel_rdt.c: In function ‘rdt_read’: src/intel_rdt.c:389:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] for (int i = 0; i < g_rdt->num_groups; i++) { ^ src/intel_rdt.c: In function ‘rdt_init’: src/intel_rdt.c:428:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] for (int i = 0; i < g_rdt->num_groups; i++) { ^ src/intel_rdt.c: In function ‘rdt_shutdown’: src/intel_rdt.c:451:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] for (int i = 0; i < g_rdt->num_groups; i++) { ^ CC src/intel_rdt_la-utils_config_cores.lo src/utils_config_cores.c: In function ‘check_core_grouping’: src/utils_config_cores.c:166:23: warning: comparison of integer expressions of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] if ((end - start) >= out_size) { ^~ CCLD intel_rdt.la --- src/intel_rdt.c | 20 ++++++++++---------- src/utils_config_cores.c | 2 +- src/utils_config_cores.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/intel_rdt.c b/src/intel_rdt.c index 684e2b6d..347835c1 100644 --- a/src/intel_rdt.c +++ b/src/intel_rdt.c @@ -67,7 +67,7 @@ static void rdt_dump_cgroups(void) { DEBUG(RDT_PLUGIN ": Core Groups Dump"); DEBUG(RDT_PLUGIN ": groups count: %" PRIsz, g_rdt->num_groups); - for (int i = 0; i < g_rdt->num_groups; i++) { + for (size_t i = 0; i < g_rdt->num_groups; i++) { core_group_t *cgroup = g_rdt->cores.cgroups + i; memset(cores, 0, sizeof(cores)); @@ -158,9 +158,9 @@ static int rdt_default_cgroups(void) { return num_cores; } -static int rdt_is_core_id_valid(int core_id) { +static int rdt_is_core_id_valid(unsigned int core_id) { - for (int i = 0; i < g_rdt->pqos_cpu->num_cores; i++) + for (unsigned int i = 0; i < g_rdt->pqos_cpu->num_cores; i++) if (core_id == g_rdt->pqos_cpu->cores[i].lcore) return 1; @@ -182,9 +182,9 @@ static int rdt_config_cgroups(oconfig_item_t *item) { for (size_t group_idx = 0; group_idx < n; group_idx++) { core_group_t *cgroup = g_rdt->cores.cgroups + group_idx; for (size_t core_idx = 0; core_idx < cgroup->num_cores; core_idx++) { - if (!rdt_is_core_id_valid((int)cgroup->cores[core_idx])) { - ERROR(RDT_PLUGIN ": Core group '%s' contains invalid core id '%d'", - cgroup->desc, (int)cgroup->cores[core_idx]); + if (!rdt_is_core_id_valid(cgroup->cores[core_idx])) { + ERROR(RDT_PLUGIN ": Core group '%s' contains invalid core id '%u'", + cgroup->desc, cgroup->cores[core_idx]); rdt_free_cgroups(); return -EINVAL; } @@ -205,7 +205,7 @@ static int rdt_config_cgroups(oconfig_item_t *item) { } /* Get all available events on this platform */ - for (int i = 0; i < g_rdt->cap_mon->u.mon->num_events; i++) + for (unsigned int i = 0; i < g_rdt->cap_mon->u.mon->num_events; i++) events |= g_rdt->cap_mon->u.mon->events[i].type; events &= ~(PQOS_PERF_EVENT_LLC_MISS); @@ -386,7 +386,7 @@ static int rdt_read(__attribute__((unused)) user_data_t *ud) { rdt_dump_data(); #endif /* COLLECT_DEBUG */ - for (int i = 0; i < g_rdt->num_groups; i++) { + for (size_t i = 0; i < g_rdt->num_groups; i++) { core_group_t *cgroup = g_rdt->cores.cgroups + i; enum pqos_mon_event mbm_events = @@ -425,7 +425,7 @@ static int rdt_init(void) { return ret; /* Start monitoring */ - for (int i = 0; i < g_rdt->num_groups; i++) { + for (size_t i = 0; i < g_rdt->num_groups; i++) { core_group_t *cg = g_rdt->cores.cgroups + i; ret = pqos_mon_start(cg->num_cores, cg->cores, g_rdt->events[i], @@ -448,7 +448,7 @@ static int rdt_shutdown(void) { return 0; /* Stop monitoring */ - for (int i = 0; i < g_rdt->num_groups; i++) { + for (size_t i = 0; i < g_rdt->num_groups; i++) { pqos_mon_stop(g_rdt->pgroups[i]); } diff --git a/src/utils_config_cores.c b/src/utils_config_cores.c index 085e8abe..94657459 100644 --- a/src/utils_config_cores.c +++ b/src/utils_config_cores.c @@ -163,7 +163,7 @@ static int check_core_grouping(char *out, const char *in, size_t out_size, ERROR(UTIL_NAME ": Missing closing bracket ] in option %s.", in); return -EINVAL; } - if ((end - start) >= out_size) { + if ((size_t)(end - start) >= out_size) { ERROR(UTIL_NAME ": Out buffer is too small."); return -EINVAL; } diff --git a/src/utils_config_cores.h b/src/utils_config_cores.h index e22cbcfe..d45f8480 100644 --- a/src/utils_config_cores.h +++ b/src/utils_config_cores.h @@ -36,7 +36,7 @@ struct core_group_s { char *desc; - unsigned *cores; + unsigned int *cores; size_t num_cores; }; typedef struct core_group_s core_group_t; -- 2.11.0