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 *autoinc, char **err);
+int parse_process_number(const char *arg, unsigned long *proc, int max, int *autoinc, char **err);
unsigned long parse_cpu_set(const char **args, unsigned long *cpu_set, char **err);
void free_email_alert(struct proxy *p);
if ((slash = strchr(args[1], '/')) != NULL)
*slash = 0;
- if (parse_process_number(args[1], &proc, &autoinc, &errmsg)) {
+ if (parse_process_number(args[1], &proc, LONGBITS, &autoinc, &errmsg)) {
ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
if (slash) {
- if (parse_process_number(slash+1, &thread, NULL, &errmsg)) {
+ if (parse_process_number(slash+1, &thread, MAX_THREADS, NULL, &errmsg)) {
ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
set = 0;
break;
}
- if (parse_process_number(args[cur_arg], &set, NULL, &errmsg)) {
+ if (parse_process_number(args[cur_arg], &set, LONGBITS, NULL, &errmsg)) {
ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
/* Parse a string representing a process number or a set of processes. It must
- * be "all", "odd", "even", a number between 1 and <LONGBITS> or a range with
+ * be "all", "odd", "even", a number between 1 and <max> or a range with
* two such numbers delimited by a dash ('-'). On success, it returns
* 0. otherwise it returns 1 with an error message in <err>.
*
* Note: this function can also be used to parse a thread number or a set of
* threads.
*/
-int parse_process_number(const char *arg, unsigned long *proc, int *autoinc, char **err)
+int parse_process_number(const char *arg, unsigned long *proc, int max, int *autoinc, char **err)
{
if (autoinc) {
*autoinc = 0;
low = high = str2uic(arg);
if ((dash = strchr(arg, '-')) != NULL)
- high = ((!*(dash+1)) ? LONGBITS : str2uic(dash + 1));
+ high = ((!*(dash+1)) ? max : str2uic(dash + 1));
if (high < low) {
unsigned int swap = low;
high = swap;
}
- if (low < 1 || low > LONGBITS || high > LONGBITS) {
+ if (low < 1 || low > max || high > max) {
memprintf(err, "'%s' is not a valid number/range."
" It supports numbers from 1 to %d.\n",
- arg, LONGBITS);
+ arg, max);
return 1;
}
for (;low <= high; low++)
*proc |= 1UL << (low-1);
}
+ *proc &= ~0UL >> (LONGBITS - max);
return 0;
}
set = 0;
break;
}
- if (parse_process_number(args[cur_arg], &set, NULL, err)) {
+ if (parse_process_number(args[cur_arg], &set, LONGBITS, NULL, err)) {
memprintf(err, "'%s %s' : %s", args[0], args[1], *err);
return -1;
}
if ((slash = strchr(args[cur_arg + 1], '/')) != NULL)
*slash = 0;
- if (parse_process_number(args[cur_arg + 1], &proc, NULL, err)) {
+ if (parse_process_number(args[cur_arg + 1], &proc, LONGBITS, NULL, err)) {
memprintf(err, "'%s' : %s", args[cur_arg], *err);
return ERR_ALERT | ERR_FATAL;
}
if (slash) {
- if (parse_process_number(slash+1, &thread, NULL, err)) {
+ if (parse_process_number(slash+1, &thread, MAX_THREADS, NULL, err)) {
memprintf(err, "'%s' : %s", args[cur_arg], *err);
return ERR_ALERT | ERR_FATAL;
}