From d6db38a318e5f9d38e5af97ab32b14bb940f50fd Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 13 Jan 2015 23:23:35 +0900 Subject: [PATCH] nghttpx: Clean up integer configuration range checking --- src/shrpx_config.cc | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 90203a0b..ed6272fe 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -1075,8 +1075,8 @@ int parse_config(const char *opt, const char *optarg) { return -1; } - if (n < 1) { - LOG(ERROR) << opt << ": specify the integer more than or equal to 1"; + if (n == 0) { + LOG(ERROR) << opt << ": specify an integer strictly more than 0"; 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)) { - int n; - - 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; + return parse_uint(&mod_config()->downstream_connections_per_frontend, opt, + optarg); } 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) { LOG(ERROR) << opt << ": specify an integer strictly more than 0"; + return -1; }