mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-02 04:46:46 -05:00
As option argument never accept an empty string for the 0 value
This commit is contained in:
parent
8ee24aa26c
commit
80bb5af22e
1 changed files with 10 additions and 9 deletions
|
|
@ -907,7 +907,7 @@ int parse_option_size(const char* arg, uint64_t* out_size)
|
||||||
|
|
||||||
/* parse the number part */
|
/* parse the number part */
|
||||||
data_off_t size = strtoul(arg, &e, 10);
|
data_off_t size = strtoul(arg, &e, 10);
|
||||||
if (!e || e == arg)
|
if (e == arg)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Handle suffixes */
|
/* Handle suffixes */
|
||||||
|
|
@ -919,7 +919,7 @@ int parse_option_size(const char* arg, uint64_t* out_size)
|
||||||
size *= GIGA;
|
size *= GIGA;
|
||||||
} else if ((e[0] == 't' || e[0] == 'T') && e[1] == 0) {
|
} else if ((e[0] == 't' || e[0] == 'T') && e[1] == 0) {
|
||||||
size *= TERA;
|
size *= TERA;
|
||||||
} else if (e[0] != '\0') {
|
} else if (e[0] != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1100,7 +1100,8 @@ int snapraid_main(int argc, char* argv[])
|
||||||
plan100 = SCRUB_FULL;
|
plan100 = SCRUB_FULL;
|
||||||
} else {
|
} else {
|
||||||
double plan_double = strtod(optarg, &e);
|
double plan_double = strtod(optarg, &e);
|
||||||
if (!e || *e != 0
|
if (e == optarg
|
||||||
|
|| *e != 0
|
||||||
|| !isfinite(plan_double)
|
|| !isfinite(plan_double)
|
||||||
|| plan_double < 0
|
|| plan_double < 0
|
||||||
|| plan_double > 100
|
|| plan_double > 100
|
||||||
|
|
@ -1115,7 +1116,7 @@ int snapraid_main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case 'o' :
|
case 'o' :
|
||||||
olderthan = strtoul(optarg, &e, 10);
|
olderthan = strtoul(optarg, &e, 10);
|
||||||
if (!e || *e || olderthan > 1000) {
|
if (e == optarg || *e || olderthan > 1000) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid number of days '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid number of days '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -1139,7 +1140,7 @@ int snapraid_main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case 'S' :
|
case 'S' :
|
||||||
blockstart = strtoul(optarg, &e, 0);
|
blockstart = strtoul(optarg, &e, 0);
|
||||||
if (!e || *e) {
|
if (e == optarg || *e) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid start position '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid start position '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -1148,7 +1149,7 @@ int snapraid_main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case 'B' :
|
case 'B' :
|
||||||
blockcount = strtoul(optarg, &e, 0);
|
blockcount = strtoul(optarg, &e, 0);
|
||||||
if (!e || *e) {
|
if (e == optarg || *e) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid count number '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid count number '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -1157,7 +1158,7 @@ int snapraid_main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case 'L' :
|
case 'L' :
|
||||||
opt.io_error_limit = strtoul(optarg, &e, 0);
|
opt.io_error_limit = strtoul(optarg, &e, 0);
|
||||||
if (!e || *e) {
|
if (e == optarg || *e) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid error limit number '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid error limit number '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -1262,7 +1263,7 @@ int snapraid_main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case OPT_GUI_THRESHOLD_REMOVES :
|
case OPT_GUI_THRESHOLD_REMOVES :
|
||||||
opt.gui_threshold_removes = strtoul(optarg, &e, 0);
|
opt.gui_threshold_removes = strtoul(optarg, &e, 0);
|
||||||
if (!e || *e) {
|
if (e == optarg || *e) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid threshold '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid threshold '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -1271,7 +1272,7 @@ int snapraid_main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case OPT_GUI_THRESHOLD_UPDATES :
|
case OPT_GUI_THRESHOLD_UPDATES :
|
||||||
opt.gui_threshold_updates = strtoul(optarg, &e, 0);
|
opt.gui_threshold_updates = strtoul(optarg, &e, 0);
|
||||||
if (!e || *e) {
|
if (e == optarg || *e) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid threshold '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid threshold '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue