From 224cb68c4ddca83f0e95daa4e97a393b3a89c471 Mon Sep 17 00:00:00 2001
From: Andrey Saranchin <Andrey22102001@gmail.com>
Date: Wed, 21 Jul 2021 14:32:23 +0300
Subject: [PATCH] build: fix build on Linux ARM64 with CMAKE_BUILD_TYPE=Debug

Fix build errors on arm64 with CMAKE_BUILD_TYPE=Debug.

Despite doubts about the correctness of http parser, keep the principle
of its work and unify behavior whether plain char is signed or unsigned.

Closes #6143
---
 changelogs/unreleased/gh-6143-arm64-debug-build |  3 +++
 src/lib/http_parser/http_parser.c               | 10 ++--------
 2 files changed, 5 insertions(+), 8 deletions(-)
 create mode 100644 changelogs/unreleased/gh-6143-arm64-debug-build

diff --git a/changelogs/unreleased/gh-6143-arm64-debug-build b/changelogs/unreleased/gh-6143-arm64-debug-build
new file mode 100644
index 0000000000..2df10486f3
--- /dev/null
+++ b/changelogs/unreleased/gh-6143-arm64-debug-build
@@ -0,0 +1,3 @@
+## bugfix/build
+
+ * Fix build errors on arm64 with `CMAKE_BUILD_TYPE=Debug`.
diff --git a/src/lib/http_parser/http_parser.c b/src/lib/http_parser/http_parser.c
index 89e40a4630..85c9e487f3 100644
--- a/src/lib/http_parser/http_parser.c
+++ b/src/lib/http_parser/http_parser.c
@@ -221,7 +221,8 @@ int
 http_parse_header_line(struct http_parser *prsr, char **bufp,
 		       const char *end_buf, int max_hname_len)
 {
-	char c, ch;
+	char c;
+	unsigned char ch;
 	char *p = *bufp;
 	char *header_name_start = p;
 	prsr->hdr_name_idx = 0;
@@ -268,10 +269,6 @@ http_parse_header_line(struct http_parser *prsr, char **bufp,
 				goto header_done;
 			default:
 				state = sw_name;
-
-				if (ch < 0) {
-					return HTTP_PARSE_INVALID;
-				}
 				c = lowcase[ch];
 				if (c != 0) {
 					prsr->hdr_name[0] = c;
@@ -306,9 +303,6 @@ http_parse_header_line(struct http_parser *prsr, char **bufp,
 			break;
 		/* http_header name */
 		case sw_name:
-			if (ch < 0) {
-				return HTTP_PARSE_INVALID;
-			}
 			c = lowcase[ch];
 			if (c != 0) {
 				if (prsr->hdr_name_idx < max_hname_len) {
-- 
GitLab