]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: config: make parse_cpu_set() return documented values
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Jul 2023 13:21:43 +0000 (15:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Jul 2023 09:01:09 +0000 (11:01 +0200)
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
src/cfgparse.c

index 7bd4725f9e81e4d16e8d8e2ae154d6e2e254f8a2..3896b57ec7f35fdee397f87288c5539203598b02 100644 (file)
@@ -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);
index bfcaba883267299decc88ec6c0954d38e6ffd05b..661f5d98082bda3fca1233bcca3d957e640fdf6c 100644 (file)
@@ -521,7 +521,7 @@ int parse_process_number(const char *arg, unsigned long *proc, int max, int *aut
  * distinct argument in <args>. On success, it returns 0, otherwise it returns
  * 1 with an error message in <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)
 {
        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;