diff --git a/src/shrpx_log.cc b/src/shrpx_log.cc index dfbadb40..27180a39 100644 --- a/src/shrpx_log.cc +++ b/src/shrpx_log.cc @@ -233,7 +233,7 @@ template std::pair copy(T n, OutputIterator d_first, OutputIterator d_last) { if (static_cast(std::distance(d_first, d_last)) < - str_size("18446744073709551615")) { + NGHTTP2_MAX_UINT64_DIGITS) { return std::make_pair(d_last, d_last); } return std::make_pair(util::utos(d_first, n), d_last); diff --git a/src/util.h b/src/util.h index 39280b4d..5be9558b 100644 --- a/src/util.h +++ b/src/util.h @@ -70,6 +70,8 @@ constexpr auto NGHTTP2_H2_14 = StringRef::from_lit("h2-14"); constexpr auto NGHTTP2_H1_1_ALPN = StringRef::from_lit("\x8http/1.1"); constexpr auto NGHTTP2_H1_1 = StringRef::from_lit("http/1.1"); +constexpr size_t NGHTTP2_MAX_UINT64_DIGITS = str_size("18446744073709551615"); + namespace util { inline bool is_alpha(const char c) { @@ -382,7 +384,7 @@ template OutputIt utos(OutputIt dst, T n) { template StringRef make_string_ref_uint(BlockAllocator &balloc, T n) { - auto iov = make_byte_ref(balloc, str_size("18446744073709551615") + 1); + auto iov = make_byte_ref(balloc, NGHTTP2_MAX_UINT64_DIGITS + 1); auto p = iov.base; p = util::utos(p, n); *p = '\0';