Skip to content

Commit

Permalink
mxqsub: Use mx_strtominutes() to parse --runtime option
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Aug 26, 2015
1 parent f805931 commit 366ae7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mxqsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,18 @@ int main(int argc, char *argv[])
mx_log_warning("option '--time' is deprecated. please use '--runtime' or '-t' in future calls.");
case 't':
if (mx_strtou32(optctl.optarg, &arg_time) < 0) {
mx_log_crit("--runtime '%s': %m", optctl.optarg);
exit(EX_CONFIG);
unsigned long long int minutes;

if(mx_strtominutes(optctl.optarg, &minutes) < 0) {
mx_log_crit("--runtime '%s': %m", optctl.optarg);
exit(EX_CONFIG);
}
if ((unsigned long long int)(uint32_t)minutes != minutes) {
errno = ERANGE;
mx_log_crit("--runtime '%s': %m", optctl.optarg);
exit(EX_CONFIG);
}
arg_time = (uint32_t)minutes;
}
break;

Expand Down
1 change: 1 addition & 0 deletions test_mx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static void test_mx_strtoul(void)
assert(mx_strtoul("-1", &l) == -ERANGE);
assert(mx_strtoul(" -1", &l) == -ERANGE);

assert(mx_strtoul("123s", &l) == -EINVAL);
assert(mx_strtoul("0888", &l) == -EINVAL);
assert(mx_strtoul("1.2", &l) == -EINVAL);
assert(mx_strtoul("1,2", &l) == -EINVAL);
Expand Down

0 comments on commit 366ae7f

Please sign in to comment.