From 6ecabb3f350885b6a1a7eefb0a76aa209baf0b1b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 6 Jul 2023 15:21:43 +0200 Subject: [PATCH] CLEANUP: config: make parse_cpu_set() return documented values parse_cpu_set() stopped returning the undocumented -1 which was a leftover from an earlier attempt, changed from ulong to int since it only returns a success/failure and no more a mask. Thus it must not return -1 and its callers must only test for != 0, as is documented. --- include/haproxy/cfgparse.h | 2 +- src/cfgparse.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/haproxy/cfgparse.h b/include/haproxy/cfgparse.h index 7bd4725f9..3896b57ec 100644 --- a/include/haproxy/cfgparse.h +++ b/include/haproxy/cfgparse.h @@ -124,7 +124,7 @@ int too_many_args(int maxarg, char **args, char **msg, int *err_code); int alertif_too_many_args_idx(int maxarg, int index, const char *file, int linenum, char **args, int *err_code); int alertif_too_many_args(int maxarg, const char *file, int linenum, char **args, int *err_code); int parse_process_number(const char *arg, unsigned long *proc, int max, int *autoinc, char **err); -unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err); +int parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err); void free_email_alert(struct proxy *p); const char *cfg_find_best_match(const char *word, const struct list *list, int section, const char **extra); int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint); diff --git a/src/cfgparse.c b/src/cfgparse.c index bfcaba883..661f5d980 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -521,7 +521,7 @@ int parse_process_number(const char *arg, unsigned long *proc, int max, int *aut * distinct argument in . On success, it returns 0, otherwise it returns * 1 with an error message in . */ -unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err) +int parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err) { int cur_arg = 0; const char *arg; @@ -535,7 +535,7 @@ unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char if (!isdigit((unsigned char)*args[cur_arg])) { memprintf(err, "'%s' is not a CPU range.", arg); - return -1; + return 1; } low = high = str2uic(arg); @@ -2645,7 +2645,7 @@ static int numa_detect_topology() parse_cpu_set_args[0] = trash.area; parse_cpu_set_args[1] = "\0"; - if (parse_cpu_set(parse_cpu_set_args, &active_cpus, &err)) { + if (parse_cpu_set(parse_cpu_set_args, &active_cpus, &err) != 0) { ha_notice("Cannot read online CPUs list: '%s'. Will not try to refine binding\n", err); free(err); goto free_scandir_entries;