Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Commit b6866a7

Browse files
committed
Fix -Wsign-compare warning
Commit 2a0d106 ("http_parser: revert `memchr()` optimization") introduced a -Wsign-compare warning that manifests itself with gcc 7.4.0 but not older versions. The type of p - q is signed when p and q are pointers and was compared against an unsigned type. Its actual value is always >= 0 however and can be safely cast to size_t. Fixes: #471 PR-URL: #472 Reviewed-By: Fedor Indutny <[email protected]>
1 parent c5c4563 commit b6866a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

http_parser.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,9 +1497,10 @@ size_t http_parser_execute (http_parser *parser,
14971497
switch (h_state) {
14981498
case h_general:
14991499
{
1500-
const char* limit = p + MIN(data + len - p, max_header_size);
1500+
size_t left = data + len - p;
1501+
const char* pe = p + MIN(left, max_header_size);
15011502

1502-
for (; p != limit; p++) {
1503+
for (; p != pe; p++) {
15031504
ch = *p;
15041505
if (ch == CR || ch == LF) {
15051506
--p;

0 commit comments

Comments
 (0)