nghttpx: Clean up integer configuration range checking

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-13 23:23:35 +09:00
parent c88a5291b7
commit d6db38a318
1 changed files with 5 additions and 17 deletions

View File

@ -1075,8 +1075,8 @@ int parse_config(const char *opt, const char *optarg) {
return -1; return -1;
} }
if (n < 1) { if (n == 0) {
LOG(ERROR) << opt << ": specify the integer more than or equal to 1"; LOG(ERROR) << opt << ": specify an integer strictly more than 0";
return -1; return -1;
} }
@ -1087,21 +1087,8 @@ int parse_config(const char *opt, const char *optarg) {
} }
if (util::strieq(opt, SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND)) { if (util::strieq(opt, SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND)) {
int n; return parse_uint(&mod_config()->downstream_connections_per_frontend, opt,
optarg);
if (parse_uint(&n, opt, optarg) != 0) {
return -1;
}
if (n < 0) {
LOG(ERROR) << opt << ": specify the integer more than or equal to 0";
return -1;
}
mod_config()->downstream_connections_per_frontend = n;
return 0;
} }
if (util::strieq(opt, SHRPX_OPT_LISTENER_DISABLE_TIMEOUT)) { if (util::strieq(opt, SHRPX_OPT_LISTENER_DISABLE_TIMEOUT)) {
@ -1139,6 +1126,7 @@ int parse_config(const char *opt, const char *optarg) {
if (n == 0) { if (n == 0) {
LOG(ERROR) << opt << ": specify an integer strictly more than 0"; LOG(ERROR) << opt << ": specify an integer strictly more than 0";
return -1; return -1;
} }