From 624d969c523808ad702c33842653b6cab179e15b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 22 Feb 2018 14:33:47 +0100 Subject: [PATCH] gluon-web: compile with -std=c99 -Wall -Wextra Also fix all warnings. --- package/gluon-web/src/Makefile | 2 +- package/gluon-web/src/template_lmo.c | 3 ++- package/gluon-web/src/template_parser.c | 2 +- package/gluon-web/src/template_utils.c | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package/gluon-web/src/Makefile b/package/gluon-web/src/Makefile index 0fa9e03c..d1c20898 100644 --- a/package/gluon-web/src/Makefile +++ b/package/gluon-web/src/Makefile @@ -1,7 +1,7 @@ all: compile %.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -D_GNU_SOURCE -fPIC -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -D_GNU_SOURCE -std=c99 -Wall -Wextra -fPIC -c -o $@ $< clean: rm -f parser.so *.o diff --git a/package/gluon-web/src/template_lmo.c b/package/gluon-web/src/template_lmo.c index 070a53df..2ea85fdf 100644 --- a/package/gluon-web/src/template_lmo.c +++ b/package/gluon-web/src/template_lmo.c @@ -27,8 +27,9 @@ static inline uint16_t get_le16(const uint8_t *d) { return (((uint16_t)d[1]) << 8) | d[0]; } -static uint32_t sfh_hash(const uint8_t *data, int len) +static uint32_t sfh_hash(const void *input, int len) { + const uint8_t *data = input; uint32_t hash = len, tmp; /* Main loop */ diff --git a/package/gluon-web/src/template_parser.c b/package/gluon-web/src/template_parser.c index 452ace20..1126ccd9 100644 --- a/package/gluon-web/src/template_parser.c +++ b/package/gluon-web/src/template_parser.c @@ -291,7 +291,7 @@ template_format_chunk(struct template_parser *parser, size_t *sz) return s; } -const char *template_reader(lua_State *L, void *ud, size_t *sz) +const char *template_reader(lua_State *L __attribute__((unused)), void *ud, size_t *sz) { struct template_parser *parser = ud; int rem = parser->size - (parser->off - parser->data); diff --git a/package/gluon-web/src/template_utils.c b/package/gluon-web/src/template_utils.c index 10f3c641..92245267 100644 --- a/package/gluon-web/src/template_utils.c +++ b/package/gluon-web/src/template_utils.c @@ -200,7 +200,7 @@ static inline int mb_is_illegal(unsigned char *s, int n) /* scan given source string, validate UTF-8 sequence and store result * in given buffer object */ -static int validate_utf8(unsigned char **s, int l, struct template_buffer *buf) +static int validate_utf8(unsigned char **s, unsigned int l, struct template_buffer *buf) { unsigned char *ptr = *s; unsigned int o = 0, v, n; @@ -289,7 +289,7 @@ char * pcdata(const char *s, unsigned int l) for (o = 0; o < l; o++) { /* Invalid XML bytes */ - if (((*ptr >= 0x00) && (*ptr <= 0x08)) || + if ((*ptr <= 0x08) || ((*ptr >= 0x0B) && (*ptr <= 0x0C)) || ((*ptr >= 0x0E) && (*ptr <= 0x1F)) || (*ptr == 0x7F))