Fix #1481 - use stricter compilation flags

This commit is contained in:
Sergey Lyubka 2022-03-06 14:31:42 +00:00
parent a284df01d1
commit 139f928731
8 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,7 @@
SRCS = mongoose.c test/unit_test.c test/packed_fs.c
HDRS = $(wildcard src/*.h)
DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1
WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wundef
WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -Wmissing-prototypes -Wstrict-prototypes -fno-common -Wconversion -Wundef
OPTS ?= -O3 -g3
INCS ?= -Isrc -I.
SSL ?= MBEDTLS
@ -62,7 +62,7 @@ unpacked:
$(CC) -I. mongoose.c test/unit_test.c -o unit_test
fuzzer: mongoose.c mongoose.h Makefile test/fuzz.c
clang mongoose.c test/fuzz.c $(WARN) $(INCS) -DMG_ENABLE_LINES -DMG_ENABLE_LOG=0 -fsanitize=fuzzer,signed-integer-overflow,address -g -o $@
clang++ mongoose.c test/fuzz.c $(WARN) $(INCS) $(TFLAGS) $(EXTRA) -DMG_ENABLE_LINES -DMG_ENABLE_LOG=0 -fsanitize=fuzzer,signed-integer-overflow,address -Wno-deprecated -o $@
fuzz: fuzzer
$(RUN) ./fuzzer

View File

@ -632,6 +632,7 @@ struct packed_file {
const char *mg_unpack(const char *path, size_t *size, time_t *mtime);
const char *mg_unlist(size_t no);
#if MG_ENABLE_PACKED_FS
#else
const char *mg_unpack(const char *path, size_t *size, time_t *mtime) {

View File

@ -562,6 +562,7 @@ size_t mg_asprintf(char **, size_t, const char *fmt, ...) PRINTF_LIKE(3, 4);
size_t mg_vasprintf(char **buf, size_t size, const char *fmt, va_list ap);
int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip);
int64_t mg_to64(struct mg_str str);
size_t mg_lld(char *buf, int64_t val, bool is_signed, bool is_hex);
@ -1141,7 +1142,6 @@ void mg_resolve_cancel(struct mg_connection *);
bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *);
size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs,
bool is_question, struct mg_dns_rr *);
size_t mg_dns_decode_name(const uint8_t *, size_t, size_t, char *, size_t);
#ifdef __cplusplus
}

View File

@ -36,4 +36,3 @@ void mg_resolve_cancel(struct mg_connection *);
bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *);
size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs,
bool is_question, struct mg_dns_rr *);
size_t mg_dns_decode_name(const uint8_t *, size_t, size_t, char *, size_t);

View File

@ -9,6 +9,7 @@ struct packed_file {
const char *mg_unpack(const char *path, size_t *size, time_t *mtime);
const char *mg_unlist(size_t no);
#if MG_ENABLE_PACKED_FS
#else
const char *mg_unpack(const char *path, size_t *size, time_t *mtime) {

View File

@ -41,3 +41,4 @@ size_t mg_asprintf(char **, size_t, const char *fmt, ...) PRINTF_LIKE(3, 4);
size_t mg_vasprintf(char **buf, size_t size, const char *fmt, va_list ap);
int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip);
int64_t mg_to64(struct mg_str str);
size_t mg_lld(char *buf, int64_t val, bool is_signed, bool is_hex);

View File

@ -33,5 +33,6 @@ struct mg_connection *mg_mkpipe(struct mg_mgr *mgr, mg_event_handler_t fn,
return NULL;
}
void _fini(void);
void _fini(void) {
}

View File

@ -25,6 +25,8 @@
#include <sys/stat.h>
static const char *code =
"const char *mg_unpack(const char *path, size_t *size, time_t *mtime);\n"
"const char *mg_unlist(size_t no);\n"
"const char *mg_unlist(size_t no) {\n"
" return packed_files[no].name;\n"
"}\n"