From c2bb9c01a6effaede81511cae91d96fec0852408 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 5 Apr 2014 19:15:45 +0900 Subject: [PATCH] nghttp: Update doc for -p option and improve error handling for it --- src/nghttp.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nghttp.cc b/src/nghttp.cc index 8c6c667e..d9afc42b 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1830,7 +1830,10 @@ Options: -d is used, the HTTP upgrade request is performed with OPTIONS method. -p, --weight= - Sets priority group weight. Default: )" + Sets priority group weight. The valid value + range is [)" + << NGHTTP2_MIN_WEIGHT << ", " << NGHTTP2_MAX_WEIGHT << R"(], inclusive. + Default: )" << NGHTTP2_DEFAULT_WEIGHT << R"( -M, --peer-max-concurrent-streams= Use as SETTINGS_MAX_CONCURRENT_STREAMS value @@ -1904,11 +1907,13 @@ int main(int argc, char **argv) config.null_out = true; break; case 'p': { + errno = 0; auto n = strtoul(optarg, nullptr, 10); - if(n <= NGHTTP2_MAX_WEIGHT) { + if(errno == 0 && NGHTTP2_MIN_WEIGHT <= n && n <= NGHTTP2_MAX_WEIGHT) { config.weight = n; } else { - std::cerr << "-p: specify the integer in the range [0, " + std::cerr << "-p: specify the integer in the range [" + << NGHTTP2_MIN_WEIGHT << ", " << NGHTTP2_MAX_WEIGHT << "], inclusive" << std::endl; exit(EXIT_FAILURE);