Without option --pid, always at least two arguments are needed:
the <priority> value and a <command>. (The 'need_prio' variable
is relevant only for the --pid case.)
Also, make the error message more informative.
CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
}
}
- if (((ctl->pid > -1) && argc - optind < (need_prio ? 1 : 0)) ||
- ((ctl->pid == -1) && argc - optind < (need_prio ? 2 : 1))) {
- warnx(_("bad usage"));
+ if (argc - optind < (ctl->pid > -1 ? 1 : 2)) {
+ warnx(_("too few arguments"));
errtryhelp(EXIT_FAILURE);
}
if (ctl->verbose)
show_sched_info(ctl);
- errno = 0;
-
- if (need_prio || argc - optind > 1)
+ if (argc - optind > 1) {
+ errno = 0;
ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
- else
+ } else
ctl->priority = 0;
if (ctl->runtime && !supports_runtime_param(ctl->policy))