Browse Source

gluon-web: compile with -std=c99 -Wall -Wextra

Also fix all warnings.
Matthias Schiffer 6 years ago
parent
commit
624d969c52

+ 1 - 1
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

+ 2 - 1
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 */

+ 1 - 1
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);

+ 2 - 2
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))