mcexec: verify argument for -n/-t/-c
This commit is contained in:
@@ -1864,16 +1864,30 @@ int main(int argc, char **argv)
|
|||||||
while ((opt = getopt_long(argc, argv, "+c:n:t:m:h:", mcexec_options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "+c:n:t:m:h:", mcexec_options, NULL)) != -1) {
|
||||||
#endif /* ADD_ENVS_OPTION */
|
#endif /* ADD_ENVS_OPTION */
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
target_core = atoi(optarg);
|
target_core = strtol(optarg, &tmp, 0);
|
||||||
|
if (*tmp != '\0') {
|
||||||
|
fprintf(stderr, "error: -c: invalid target CPU\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
nr_processes = atoi(optarg);
|
nr_processes = strtol(optarg, &tmp, 0);
|
||||||
|
if (*tmp != '\0' || nr_processes <= 0) {
|
||||||
|
fprintf(stderr, "error: -n: invalid number of processes\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
nr_threads = atoi(optarg);
|
nr_threads = strtol(optarg, &tmp, 0);
|
||||||
|
if (*tmp != '\0' || nr_threads <= 0) {
|
||||||
|
fprintf(stderr, "error: -t: invalid number of threads\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
|
|||||||
Reference in New Issue
Block a user