From b8f5a986e7cbe61f648518e47a159d032923d1b4 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 11:39:06 +0100 Subject: [PATCH 01/12] sys_ident: Quiet strncpy warning The string is terminated by explicit NUL assignement below, use memcpy instead of strncpy. --- src/sys_ident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys_ident.c b/src/sys_ident.c index 2c5c06b4..20fe2e87 100644 --- a/src/sys_ident.c +++ b/src/sys_ident.c @@ -386,7 +386,7 @@ print_sys_part_id(void) close(fd); - strncpy(tttt, model+4, 4); + memcpy(tttt, model+4, 4); tttt[4] = '\0'; fd = open("/proc/device-tree/ibm,partition-no", O_RDONLY); From d277307463737277adab8ba2634cf913cf8a71a7 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 11:41:27 +0100 Subject: [PATCH 02/12] lparstat: Quiet warning about calloc argument order The documentation sttes that the element size should come second but it's passed first. --- src/lparstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lparstat.c b/src/lparstat.c index fe8b0fcc..54d2bcd7 100644 --- a/src/lparstat.c +++ b/src/lparstat.c @@ -134,7 +134,7 @@ static int assign_cpu_sysfs_fds(int threads_in_system) char sysfs_file_path[SYSFS_PATH_MAX]; cpu_sysfs_fds = - (cpu_sysfs_fd*)calloc(sizeof(cpu_sysfs_fd), threads_in_system); + (cpu_sysfs_fd*)calloc(threads_in_system, sizeof(cpu_sysfs_fd)); if (!cpu_sysfs_fds) { fprintf(stderr, "Failed to allocate memory for sysfs file descriptors\n"); return -1; From 1ad0a3f9844dccd2e87854f01e388798d66487c3 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 11:46:56 +0100 Subject: [PATCH 03/12] drmgr: Make usr_drc_count unsigned There is no point to it being signed other than the trick of negating to record removal. It is compared to unsigned values in a number of places leading to a warning. --- src/drmgr/common.c | 6 +++--- src/drmgr/dr.h | 2 +- src/drmgr/dracc_chrp_acc.c | 5 ----- src/drmgr/options.c | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/drmgr/common.c b/src/drmgr/common.c index 70f4dfda..4e4defde 100644 --- a/src/drmgr/common.c +++ b/src/drmgr/common.c @@ -1270,10 +1270,10 @@ int update_sysparm(void) return 1; } - usr_drc_count = -usr_drc_count; + return set_sysparm(linux_parm, curval - usr_drc_count); + } else { + return set_sysparm(linux_parm, curval + usr_drc_count); } - - return set_sysparm(linux_parm, curval + usr_drc_count); } int diff --git a/src/drmgr/dr.h b/src/drmgr/dr.h index 72ede555..ce6ce547 100644 --- a/src/drmgr/dr.h +++ b/src/drmgr/dr.h @@ -79,7 +79,7 @@ extern int usr_timeout; extern char *usr_drc_name; extern uint32_t usr_drc_index; extern int usr_prompt; -extern int usr_drc_count; +extern unsigned usr_drc_count; extern enum drc_type usr_drc_type; extern char *usr_p_option; extern char *usr_t_option; diff --git a/src/drmgr/dracc_chrp_acc.c b/src/drmgr/dracc_chrp_acc.c index 527be56a..b8e2f755 100644 --- a/src/drmgr/dracc_chrp_acc.c +++ b/src/drmgr/dracc_chrp_acc.c @@ -79,11 +79,6 @@ int dracc_chrp_acc(void) return -1; } - if (usr_drc_count < 0) { - say(ERROR, "Invalid QoS credit count %d\n", usr_drc_count); - return -1; - } - fd = open(SYSFS_VAS_QOSCREDIT_FILE, O_WRONLY); if (fd < 0) { say(ERROR, "Could not open \"%s\" to write QoS credits\n", diff --git a/src/drmgr/options.c b/src/drmgr/options.c index fba91586..79250720 100644 --- a/src/drmgr/options.c +++ b/src/drmgr/options.c @@ -45,7 +45,7 @@ int usr_prompt = 1; /* user-specified quantity of devices to add/remove */ /* user-specified quantity of accelerator QoS credits to assign */ -int usr_drc_count = 0; +unsigned usr_drc_count = 0; /* user specified drc type to use */ enum drc_type usr_drc_type = DRC_TYPE_NONE; From fcd4b0e013072081dcc2284fede8a764eb7b518e Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:01:38 +0100 Subject: [PATCH 04/12] drmgr: Make output_level unsigned output_level is compared to say_level enumeration values which are all non-negative, making the enumeration type unsigned. This comparison triggers a warning. --- src/drmgr/common.c | 2 +- src/drmgr/dr.h | 4 ++-- src/drmgr/drmgr.c | 4 ++-- src/drmgr/lparnumascore.c | 4 ++-- src/drmgr/lsslot.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/drmgr/common.c b/src/drmgr/common.c index 4e4defde..45a3ddeb 100644 --- a/src/drmgr/common.c +++ b/src/drmgr/common.c @@ -94,7 +94,7 @@ static const char * const hook_action_name[] = { * @param level level to set the output level to */ inline void -set_output_level(int level) +set_output_level(unsigned level) { output_level = level; diff --git a/src/drmgr/dr.h b/src/drmgr/dr.h index ce6ce547..3d946c66 100644 --- a/src/drmgr/dr.h +++ b/src/drmgr/dr.h @@ -30,7 +30,7 @@ #include "rtas_calls.h" #include "drpci.h" -extern int output_level; +extern unsigned output_level; extern int log_fd; extern int read_dynamic_memory_v2; @@ -133,7 +133,7 @@ int cpu_entitlement_capable(void); int mem_entitlement_capable(void); void print_dlpar_capabilities(void); -void set_output_level(int); +void set_output_level(unsigned); int run_hooks(enum drc_type drc_type, enum drmgr_action, enum hook_phase phase, int drc_count); diff --git a/src/drmgr/drmgr.c b/src/drmgr/drmgr.c index bb3e1758..01f4cc11 100644 --- a/src/drmgr/drmgr.c +++ b/src/drmgr/drmgr.c @@ -32,7 +32,7 @@ #define DRMGR_ARGS "ac:d:Iimnp:P:Qq:Rrs:w:t:hCVH" -int output_level = 1; /* default to lowest output level */ +unsigned output_level = 1; /* default to lowest output level */ int log_fd = 0; int action_cnt = 0; @@ -202,7 +202,7 @@ int parse_options(int argc, char *argv[]) display_capabilities = 1; break; case 'd': - set_output_level(atoi(optarg)); + set_output_level(strtoul(optarg, NULL, 10)); break; case 'I': usr_slot_identification = 0; diff --git a/src/drmgr/lparnumascore.c b/src/drmgr/lparnumascore.c index ffb974c5..56ad85a9 100644 --- a/src/drmgr/lparnumascore.c +++ b/src/drmgr/lparnumascore.c @@ -39,7 +39,7 @@ #define NUMA_NO_NODE -1 -int output_level = 0; +unsigned output_level = 0; int log_fd = 0; int min_common_depth; int read_dynamic_memory_v2 = 1; @@ -249,7 +249,7 @@ static int parse_options(int argc, char *argv[]) } break; case 'd': - set_output_level(atoi(optarg)); + set_output_level(strtoul(optarg, NULL, 10)); break; case 'h': usage(); diff --git a/src/drmgr/lsslot.c b/src/drmgr/lsslot.c index 83e9e85b..6a0c3058 100644 --- a/src/drmgr/lsslot.c +++ b/src/drmgr/lsslot.c @@ -33,7 +33,7 @@ #include "options.c" -int output_level = 0; +unsigned output_level = 0; int log_fd = 0; int read_dynamic_memory_v2 = 1; @@ -435,7 +435,7 @@ static void parse_options(int argc, char *argv[]) break; case 'd': - set_output_level(atoi(optarg)); + set_output_level(strtoul(optarg, NULL, 10)); break; case 'F': From 088e7566c815872f24858062bfc6f577f0d6db05 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:15:25 +0100 Subject: [PATCH 05/12] drmgr: Make property size signed Property size is compared with file size returned from the stat() call which is signed. --- src/drmgr/common.c | 8 ++++---- src/drmgr/dr.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/drmgr/common.c b/src/drmgr/common.c index 45a3ddeb..15f8939b 100644 --- a/src/drmgr/common.c +++ b/src/drmgr/common.c @@ -730,7 +730,7 @@ update_property(const char *buf, size_t len) * @returns 0 on success, -1 otherwise */ static int -get_att_prop(const char *path, const char *name, char *buf, size_t buf_sz, +get_att_prop(const char *path, const char *name, char *buf, ssize_t buf_sz, const char *attr_type) { FILE *fp; @@ -797,7 +797,7 @@ get_att_prop(const char *path, const char *name, char *buf, size_t buf_sz, * @returns 0 on success, !0 otherwise */ int -get_property(const char *path, const char *property, void *buf, size_t buf_sz) +get_property(const char *path, const char *property, void *buf, ssize_t buf_sz) { return get_att_prop(path, property, buf, buf_sz, NULL); } @@ -814,7 +814,7 @@ get_property(const char *path, const char *property, void *buf, size_t buf_sz) */ int get_int_attribute(const char *path, const char *attribute, void *buf, - size_t buf_sz) + ssize_t buf_sz) { return get_att_prop(path, attribute, buf, buf_sz, "%i"); } @@ -831,7 +831,7 @@ get_int_attribute(const char *path, const char *attribute, void *buf, */ int get_str_attribute(const char *path, const char *attribute, void *buf, - size_t buf_sz) + ssize_t buf_sz) { return get_att_prop(path, attribute, buf, buf_sz, "%s"); } diff --git a/src/drmgr/dr.h b/src/drmgr/dr.h index 3d946c66..a369a6e1 100644 --- a/src/drmgr/dr.h +++ b/src/drmgr/dr.h @@ -110,9 +110,9 @@ int add_device_tree_nodes(char *, struct of_node *); int remove_device_tree_nodes(const char *path); int update_property(const char *, size_t); -int get_property(const char *, const char *, void *, size_t); -int get_int_attribute(const char *, const char *, void *, size_t); -int get_str_attribute(const char *, const char *, void *, size_t); +int get_property(const char *, const char *, void *, ssize_t); +int get_int_attribute(const char *, const char *, void *, ssize_t); +int get_str_attribute(const char *, const char *, void *, ssize_t); int get_ofdt_uint_property(const char *, const char *, uint *); int get_property_size(const char *, const char *); int signal_handler(int, int, struct sigcontext *); From e245be6de6ab603c28b6ac44b7fdb07337fed33e Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:42:54 +0100 Subject: [PATCH 06/12] drmgr: make nid unsigned The structures that store nid values store them as unsigned, causing different signedness comparison warnings. --- src/drmgr/common_numa.c | 5 +++-- src/drmgr/common_numa.h | 6 +++--- src/drmgr/drslot_chrp_mem.c | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/drmgr/common_numa.c b/src/drmgr/common_numa.c index 898aab6f..cf8a1cfe 100644 --- a/src/drmgr/common_numa.c +++ b/src/drmgr/common_numa.c @@ -27,7 +27,7 @@ #include "drmem.h" /* for DYNAMIC_RECONFIG_MEM */ #include "common_numa.h" -struct ppcnuma_node *ppcnuma_fetch_node(struct ppcnuma_topology *numa, int nid) +struct ppcnuma_node *ppcnuma_fetch_node(struct ppcnuma_topology *numa, unsigned nid) { struct ppcnuma_node *node; @@ -67,7 +67,8 @@ static int read_numa_topology(struct ppcnuma_topology *numa) { struct bitmask *cpus; struct ppcnuma_node *node; - int rc, max_node, nid, i; + int rc; + unsigned max_node, nid, i; if (numa_available() < 0) return -ENOENT; diff --git a/src/drmgr/common_numa.h b/src/drmgr/common_numa.h index c209a3ef..06e28cec 100644 --- a/src/drmgr/common_numa.h +++ b/src/drmgr/common_numa.h @@ -46,10 +46,10 @@ struct ppcnuma_topology { int ppcnuma_get_topology(struct ppcnuma_topology *numa); struct ppcnuma_node *ppcnuma_fetch_node(struct ppcnuma_topology *numa, - int node_id); + unsigned node_id); -static inline int ppcnuma_next_node(struct ppcnuma_topology *numa, int nid, - struct ppcnuma_node **node) +static inline unsigned ppcnuma_next_node(struct ppcnuma_topology *numa, unsigned nid, + struct ppcnuma_node **node) { for (nid++; nid <= numa->node_max; nid++) if (numa->nodes[nid]) { diff --git a/src/drmgr/drslot_chrp_mem.c b/src/drmgr/drslot_chrp_mem.c index d37ee80a..dec9c4c4 100644 --- a/src/drmgr/drslot_chrp_mem.c +++ b/src/drmgr/drslot_chrp_mem.c @@ -312,12 +312,14 @@ get_mem_node_lmbs(struct lmb_list_head *lmb_list) static int link_lmb_to_numa_node(struct dr_node *lmb) { - int nid; + int ret; + unsigned nid; struct ppcnuma_node *node; - nid = aa_index_to_node(&numa.aa, lmb->lmb_aa_index); - if (nid == -1) + ret = aa_index_to_node(&numa.aa, lmb->lmb_aa_index); + if (ret == -1) return 0; + nid = ret; node = ppcnuma_fetch_node(&numa, nid); if (!node) @@ -1521,7 +1523,7 @@ static int remove_lmb_from_node(struct ppcnuma_node *node, uint32_t count) static void update_cpuless_node_ratio(void) { struct ppcnuma_node *node; - int nid; + unsigned nid; /* * Assumptions: @@ -1549,7 +1551,7 @@ static void update_cpuless_node_ratio(void) static int remove_cpuless_lmbs(uint32_t count) { struct ppcnuma_node *node; - int nid; + unsigned nid; uint32_t total = count, todo, done = 0, this_loop; while (count) { @@ -1593,7 +1595,7 @@ static int remove_cpuless_lmbs(uint32_t count) static void update_node_ratio(void) { - int nid; + unsigned nid; struct ppcnuma_node *node, *n, **p; uint32_t cpu_ratio, mem_ratio; @@ -1695,7 +1697,7 @@ static void build_numa_topology(void) static void clear_numa_lmb_links(void) { - int nid; + unsigned nid; struct ppcnuma_node *node; ppcnuma_foreach_node(&numa, nid, node) @@ -1706,7 +1708,7 @@ static int numa_based_remove(uint32_t count) { struct lmb_list_head *lmb_list; struct ppcnuma_node *node; - int nid; + unsigned nid; uint32_t done = 0; /* From b771301718b36df8cd9807696121215778a0bb08 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:41:15 +0100 Subject: [PATCH 07/12] Make min_commom_depth unsigned --- src/drmgr/common_ofdt.c | 4 ++-- src/drmgr/lparnumascore.c | 9 ++++++--- src/drmgr/ofdt.h | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/drmgr/common_ofdt.c b/src/drmgr/common_ofdt.c index 1e5fe53b..145fa8a9 100644 --- a/src/drmgr/common_ofdt.c +++ b/src/drmgr/common_ofdt.c @@ -857,7 +857,7 @@ int get_min_common_depth(void) } int get_assoc_arrays(const char *dir, struct assoc_arrays *aa, - int min_common_depth) + unsigned min_common_depth) { int size; int rc; @@ -908,7 +908,7 @@ int get_assoc_arrays(const char *dir, struct assoc_arrays *aa, * Read the associativity property and return the node id matching the * min_common_depth entry. */ -int of_associativity_to_node(const char *dir, int min_common_depth) +int of_associativity_to_node(const char *dir, unsigned min_common_depth) { int size; uint32_t *prop; diff --git a/src/drmgr/lparnumascore.c b/src/drmgr/lparnumascore.c index 56ad85a9..559d8388 100644 --- a/src/drmgr/lparnumascore.c +++ b/src/drmgr/lparnumascore.c @@ -41,7 +41,7 @@ unsigned output_level = 0; int log_fd = 0; -int min_common_depth; +unsigned min_common_depth; int read_dynamic_memory_v2 = 1; static bool check_node(char *syspath, int node) @@ -276,6 +276,8 @@ static int parse_options(int argc, char *argv[]) int main(int argc, char *argv[]) { + int rc; + if (parse_options(argc, argv)) exit(1); @@ -290,9 +292,10 @@ int main(int argc, char *argv[]) exit(1); } - min_common_depth = get_min_common_depth(); - if (min_common_depth < 0) + rc = get_min_common_depth(); + if (rc < 0) exit(1); + min_common_depth = rc; switch (usr_drc_type) { case DRC_TYPE_CPU: diff --git a/src/drmgr/ofdt.h b/src/drmgr/ofdt.h index e9ebd036..ca28b4c7 100644 --- a/src/drmgr/ofdt.h +++ b/src/drmgr/ofdt.h @@ -182,8 +182,8 @@ int get_drc_by_index(uint32_t, struct dr_connector *, char *, char *); int get_min_common_depth(void); int get_assoc_arrays(const char *dir, struct assoc_arrays *aa, - int min_common_depth); -int of_associativity_to_node(const char *dir, int min_common_depth); + unsigned min_common_depth); +int of_associativity_to_node(const char *dir, unsigned min_common_depth); int init_node(struct dr_node *); static inline int aa_index_to_node(struct assoc_arrays *aa, uint32_t aa_index) From 9c1b1301ea79c4eed582c7918aea544858d10e13 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:23:51 +0100 Subject: [PATCH 08/12] rtas_dbg: RTAS token value should be unsigned The token value is comparted to an unsigned value, and the string representation is assumed to start with a number, not a sign. --- src/rtas_dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rtas_dbg.c b/src/rtas_dbg.c index 6c7854a2..a7381130 100644 --- a/src/rtas_dbg.c +++ b/src/rtas_dbg.c @@ -182,7 +182,7 @@ struct rtas_token *get_rtas_token_by_name(char *name, return NULL; } -struct rtas_token *get_rtas_token_by_value(int value, +struct rtas_token *get_rtas_token_by_value(unsigned value, struct rtas_token *tok_list) { struct rtas_token *tok; @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) } if ((dbg_arg[0] >= '0') && (dbg_arg[0] <= '9')) - tok = get_rtas_token_by_value(strtol(dbg_arg, NULL, 0), + tok = get_rtas_token_by_value(strtoul(dbg_arg, NULL, 0), tok_list); else tok = get_rtas_token_by_name(dbg_arg, tok_list); From c2cebee270bfdc236690d9300556aad79ef8d97c Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:35:55 +0100 Subject: [PATCH 09/12] Make variaus local variables compared to unsigned values also unsigned --- src/drmgr/common_pci.c | 2 +- src/drmgr/drslot_chrp_mem.c | 7 ++++--- src/nvram.c | 7 ++++--- src/ppc64_cpu.c | 2 +- src/uesensor.c | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/drmgr/common_pci.c b/src/drmgr/common_pci.c index 683d72d3..8226e63a 100644 --- a/src/drmgr/common_pci.c +++ b/src/drmgr/common_pci.c @@ -1050,7 +1050,7 @@ get_bus_id(char *loc_code) DIR *d; struct dirent *ent; char *dir = "/sys/bus/pci/slots"; - int inlen; + size_t inlen; char *ptr; /* Strip any newline from the input location */ diff --git a/src/drmgr/drslot_chrp_mem.c b/src/drmgr/drslot_chrp_mem.c index dec9c4c4..f6600599 100644 --- a/src/drmgr/drslot_chrp_mem.c +++ b/src/drmgr/drslot_chrp_mem.c @@ -441,7 +441,8 @@ int get_dynamic_reconfig_lmbs_v2(uint64_t lmb_sz, { struct drconf_mem_v2 *drmem; uint32_t lmb_sets; - int i, rc = 0; + unsigned i; + int rc; lmb_list->drconf_buf_sz = get_property_size(DYNAMIC_RECONFIG_MEM, "ibm,dynamic-memory-v2"); @@ -471,7 +472,7 @@ int get_dynamic_reconfig_lmbs_v2(uint64_t lmb_sz, for (i = 0; i < lmb_sets; i++) { uint32_t drc_index, seq_lmbs; uint64_t address; - int j; + unsigned j; address = be64toh(drmem->base_addr); drc_index = be32toh(drmem->drc_index); @@ -741,7 +742,7 @@ static void update_drconf_affinity(struct dr_node *lmb, uint32_t assoc_entries; uint32_t assoc_entry_sz; uint32_t *prop_val; - int i; + unsigned i; /* find the ibm,associativity property */ node = lmb->lmb_of_node; diff --git a/src/nvram.c b/src/nvram.c index 1987c3d9..7c40cf78 100644 --- a/src/nvram.c +++ b/src/nvram.c @@ -670,7 +670,7 @@ getsmallvalue(char *p, char *buf) static char * lookupfield(char *p) { - int i; + unsigned i; for (i = 0; (i < sizeof(descs) / sizeof(descs[0])); i++) { if (strcmp(p, descs[i].name) == 0) @@ -1181,7 +1181,7 @@ print_of_config_part(struct nvram *nvram, char *pname) { struct partition_header *phead; char *data; - int i; + unsigned i; phead = nvram_find_partition(nvram, 0, pname, NULL); if (phead == NULL) @@ -1223,7 +1223,8 @@ print_of_config(struct nvram *nvram, char *config_var, char *pname, { struct partition_header *phead; char *data, terminator; - int i, varlen; + int i; + size_t varlen; int rc = -1; terminator = '\n'; diff --git a/src/ppc64_cpu.c b/src/ppc64_cpu.c index ad9f4dce..d6f33c5a 100644 --- a/src/ppc64_cpu.c +++ b/src/ppc64_cpu.c @@ -792,7 +792,7 @@ static void report_system_power_mode(void) static void setrlimit_open_files(void) { struct rlimit old_rlim, new_rlim; - int new = threads_in_system + 8; + unsigned new = threads_in_system + 8; getrlimit(RLIMIT_NOFILE, &old_rlim); diff --git a/src/uesensor.c b/src/uesensor.c index 0420137e..ea17aff3 100644 --- a/src/uesensor.c +++ b/src/uesensor.c @@ -422,6 +422,8 @@ main (int argc, char **argv) } if (text || numerical) { + unsigned i; + /* Print the status/value of all sensors */ fd = open(PATH_RTAS_SENSORS, O_RDONLY); From ae292ebe1600e4e168c77871d8c284e4362e94c4 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:39:00 +0100 Subject: [PATCH 10/12] Make a few progress counters unsigned They are compared to an unsigned value causing a different sign comparison warning. These start from zero and only increase, there is no use for negative values. --- src/drmgr/drmem.h | 2 +- src/drmgr/drslot_chrp_cpu.c | 7 ++++--- src/drmgr/drslot_chrp_mem.c | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/drmgr/drmem.h b/src/drmgr/drmem.h index 48108c52..550cbd2d 100644 --- a/src/drmgr/drmem.h +++ b/src/drmgr/drmem.h @@ -24,7 +24,7 @@ struct lmb_list_head { struct dr_node *last; char *drconf_buf; int drconf_buf_sz; - int lmbs_modified; + unsigned lmbs_modified; int sort; int lmbs_found; }; diff --git a/src/drmgr/drslot_chrp_cpu.c b/src/drmgr/drslot_chrp_cpu.c index 3ef24f43..a6bac4a9 100644 --- a/src/drmgr/drslot_chrp_cpu.c +++ b/src/drmgr/drslot_chrp_cpu.c @@ -231,7 +231,7 @@ struct dr_node *get_available_cpu(struct dr_info *dr_info) * @param nr_cpus * @returns 0 on success, !0 otherwise */ -static int add_cpus(struct dr_info *dr_info, int *count) +static int add_cpus(struct dr_info *dr_info, unsigned *count) { int rc = -1; struct dr_node *cpu = NULL; @@ -285,7 +285,7 @@ static int add_cpus(struct dr_info *dr_info, int *count) * @param nr_cpus * @returns 0 on success, !0 otherwise */ -static int remove_cpus(struct dr_info *dr_info, int *count) +static int remove_cpus(struct dr_info *dr_info, unsigned *count) { int rc = 0; struct dr_node *cpu; @@ -405,7 +405,8 @@ int valid_cpu_options(void) int drslot_chrp_cpu(void) { struct dr_info dr_info; - int rc, count = 0; + int rc; + unsigned count = 0; if (! cpu_dlpar_capable()) { say(ERROR, "CPU DLPAR capability is not enabled on this " diff --git a/src/drmgr/drslot_chrp_mem.c b/src/drmgr/drslot_chrp_mem.c index f6600599..395997ba 100644 --- a/src/drmgr/drslot_chrp_mem.c +++ b/src/drmgr/drslot_chrp_mem.c @@ -1473,7 +1473,8 @@ static int remove_lmb_by_index(uint32_t drc_index) static int remove_lmb_from_node(struct ppcnuma_node *node, uint32_t count) { struct dr_node *lmb; - int err, done = 0, unlinked = 0; + int err; + unsigned done = 0, unlinked = 0; say(DEBUG, "Try removing %d / %d LMBs from node %d\n", count, node->n_lmbs, node->node_id); From 216686c68fb22dc7fda52aef69d6aaf8aae1a624 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:42:13 +0100 Subject: [PATCH 11/12] Add a cast to a couple of expressions This avoids different signedness warning. --- src/drmgr/common_ofdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drmgr/common_ofdt.c b/src/drmgr/common_ofdt.c index 145fa8a9..02c1f70d 100644 --- a/src/drmgr/common_ofdt.c +++ b/src/drmgr/common_ofdt.c @@ -844,7 +844,7 @@ int get_min_common_depth(void) size = load_property(RTAS_DIRECTORY, ASSOC_REF_POINTS, &p); if (size <= 0) return size; - if (size < sizeof(uint32_t)) { + if (size < (int)sizeof(uint32_t)) { report_unknown_error(__FILE__, __LINE__); free(p); return -EINVAL; @@ -884,7 +884,7 @@ int get_assoc_arrays(const char *dir, struct assoc_arrays *aa, } /* Sanity check */ - if (size != (aa->n_arrays * aa->array_sz + 2)) { + if ((unsigned)size != (aa->n_arrays * aa->array_sz + 2)) { say(ERROR, "Bad size of the associativity lookup arrays\n"); goto out_free; } From ed98c7745f84c80efc066e16717de9b71d04dabd Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 4 Nov 2024 12:48:50 +0100 Subject: [PATCH 12/12] CI: Enable -Wextra --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 434877e9..1c503278 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: - name: configure run: | - ./configure --prefix=/usr --host=${{ matrix.host }} --enable-werror --build=x86_64-linux-gnu CFLAGS='-O2 -g' + ./configure --prefix=/usr --host=${{ matrix.host }} --enable-werror --build=x86_64-linux-gnu CFLAGS='-O2 -g -Wextra -Wno-error=unused-parameter -Wno-error=nonnull' - name: Collect config.log if: ${{ failure() }}