From: Joshua Rogers Date: Sat, 6 Sep 2025 07:04:21 +0000 (+0000) Subject: Consistently check strcspn return value (#2166) X-Git-Tag: SQUID_7_2~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d15e64b1d53f6c4d797fde514798aa236b6fce99;p=thirdparty%2Fsquid.git Consistently check strcspn return value (#2166) --- diff --git a/src/format/Format.cc b/src/format/Format.cc index 486da88c32..1dd26e7346 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -294,7 +294,7 @@ log_quoted_string(const char *str, char *out) char *p = out; while (*str) { - int l = strcspn(str, "\"\\\r\n\t"); + const auto l = strcspn(str, "\"\\\r\n\t"); memcpy(p, str, l); str += l; p += l; diff --git a/src/format/Token.cc b/src/format/Token.cc index 3b1da3e5bc..0b569c2430 100644 --- a/src/format/Token.cc +++ b/src/format/Token.cc @@ -354,9 +354,7 @@ Format::Token::parse(const char *def, Quoting *quoting) { const char *cur = def; - int l; - - l = strcspn(cur, "%"); + auto l = strcspn(cur, "%"); if (l > 0) { char *cp; diff --git a/src/http/Message.cc b/src/http/Message.cc index 7c575eb249..bd40c89497 100644 --- a/src/http/Message.cc +++ b/src/http/Message.cc @@ -41,7 +41,7 @@ Http::Message::putCc(const HttpHdrCc &otherCc) static int httpMsgIsolateStart(const char **parse_start, const char **blk_start, const char **blk_end) { - int slen = strcspn(*parse_start, "\r\n"); + const auto slen = strcspn(*parse_start, "\r\n"); if (!(*parse_start)[slen]) /* no CRLF found */ return 0; diff --git a/src/tools.cc b/src/tools.cc index cbc74d05c9..0b1c73c4f4 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1087,7 +1087,7 @@ strwordquote(MemBuf * mb, const char *str) } while (*str) { - int l = strcspn(str, "\"\\\n\r"); + const auto l = strcspn(str, "\"\\\n\r"); mb->append(str, l); str += l;