http-parser.c

Small C library to parse HTTP requests
Log | Files | Refs | README | LICENSE

commit 2ad2f7493c3aaaeee35f4850fe166e2c3d570fb8
parent d83e96dec420d4381afb9a503dbd44cf95e5b2b3
Author: finwo <finwo@pm.me>
Date:   Fri,  4 Aug 2023 19:33:49 +0200

Enabled build warnings and removed them

Diffstat:
MMakefile | 4+++-
Msrc/http-parser.c | 6+-----
2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,10 +1,12 @@ SRC=$(wildcard src/*.c) SRC+=test.c +override CFLAGS?=-Wall -s -O2 + include lib/.dep/config.mk http-parser-test: $(SRC) src/http-parser-statusses.h src/http-parser.h - $(CC) -Isrc $(INCLUDES) -o $@ $(SRC) + $(CC) -Isrc $(INCLUDES) $(CFLAGS) -o $@ $(SRC) .PHONY: check check: http-parser-test diff --git a/src/http-parser.c b/src/http-parser.c @@ -235,7 +235,7 @@ static int http_parser_message_read_header(struct http_parser_message *message) } // Prepare new header - header = calloc(1,sizeof(header)); + header = calloc(1,sizeof(struct http_parser_message)); header->key = calloc(1,strlen(message->body->data)); // Using strlen, due to possible \r\n replacement header->value = calloc(1,strlen(message->body->data)); // Using strlen, due to possible \r\n replacement @@ -371,8 +371,6 @@ struct buf * http_parser_sprint_response(struct http_parser_message *response) { result->cap = 65536; result->data = calloc(1, result->cap); - int index, length; - // Status sprintf(result->data, "HTTP/%s %d %s\r\n" @@ -401,8 +399,6 @@ struct buf * http_parser_sprint_request(struct http_parser_message *request) { result->cap = 65536; result->data = calloc(1, result->cap); - int index, length; - // Status sprintf(result->data, "%s %s"