From 9273be17a6ddbc1b142cf67f097de978a5a97ceb Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 28 Jun 2014 13:37:50 +0200 Subject: compile with -Wextra, ignore unused parameters Signed-off-by: Hiltjo Posthuma --- config.mk | 2 +- sfeed.c | 31 ++++++++++++++++++++++++++----- sfeed_opml_import.c | 12 ++++++++++++ sfeed_web.c | 11 +++++++++++ sfeed_xmlenc.c | 14 +++++++++++++- 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/config.mk b/config.mk index 4fd021d..643b0b3 100644 --- a/config.mk +++ b/config.mk @@ -12,7 +12,7 @@ INCS = LIBS = -lc # debug -CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -pedantic \ +CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -Wextra -pedantic \ -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE LDFLAGS = ${LIBS} diff --git a/sfeed.c b/sfeed.c index a42d6bd..7732513 100644 --- a/sfeed.c +++ b/sfeed.c @@ -244,6 +244,7 @@ static int string_buffer_realloc(String *s, size_t newlen) { char *p; size_t alloclen; + for(alloclen = 16; alloclen <= newlen; alloclen *= 2); if(!(p = realloc(s->data, alloclen))) { string_free(s); /* free previous allocation */ @@ -405,13 +406,19 @@ xml_handler_data(XMLParser *p, const char *s, size_t len) { static void xml_handler_cdata(XMLParser *p, const char *s, size_t len) { + (void)p; + if(ctx.field) string_append(ctx.field, s, len); } static void xml_handler_attr_start(struct xmlparser *p, const char *tag, size_t taglen, - const char *name, size_t namelen) { + const char *name, size_t namelen) +{ + (void)tag; + (void)taglen; + if(ctx.iscontent && !ctx.iscontenttag) { if(!ctx.attrcount) xml_handler_data(p, " ", 1); @@ -424,7 +431,13 @@ xml_handler_attr_start(struct xmlparser *p, const char *tag, size_t taglen, static void xml_handler_attr_end(struct xmlparser *p, const char *tag, size_t taglen, - const char *name, size_t namelen) { + const char *name, size_t namelen) +{ + (void)tag; + (void)taglen; + (void)name; + (void)namelen; + if(ctx.iscontent && !ctx.iscontenttag) { xml_handler_data(p, "\"", 1); ctx.attrcount = 0; @@ -433,7 +446,11 @@ xml_handler_attr_end(struct xmlparser *p, const char *tag, size_t taglen, static void xml_handler_start_element_parsed(XMLParser *p, const char *tag, size_t taglen, - int isshort) { + int isshort) +{ + (void)tag; + (void)taglen; + if(ctx.iscontent && !ctx.iscontenttag) { if(isshort) xml_handler_data(p, "/>", 2); @@ -444,8 +461,12 @@ xml_handler_start_element_parsed(XMLParser *p, const char *tag, size_t taglen, static void xml_handler_attr(XMLParser *p, const char *tag, size_t taglen, - const char *name, size_t namelen, const char *value, - size_t valuelen) { + const char *name, size_t namelen, const char *value, + size_t valuelen) +{ + (void)tag; + (void)taglen; + if(ctx.iscontent && !ctx.iscontenttag) { xml_handler_data(p, value, valuelen); return; diff --git a/sfeed_opml_import.c b/sfeed_opml_import.c index f472cb0..ec54d9e 100644 --- a/sfeed_opml_import.c +++ b/sfeed_opml_import.c @@ -22,6 +22,9 @@ isattr(const char *s1, const char *s2) { static void xml_handler_start_element(XMLParser *p, const char *tag, size_t taglen) { + (void)p; + (void)taglen; + if(istag(tag, "outline")) { feedurl[0] = '\0'; feedname[0] = '\0'; @@ -33,6 +36,10 @@ static void xml_handler_end_element(XMLParser *p, const char *tag, size_t taglen, int isshort) { + (void)p; + (void)taglen; + (void)isshort; + if(istag(tag, "outline")) { printf("\tfeed \"%s\" \"%s\" \"%s\"\n", feedname[0] ? feedname : "unnamed", @@ -45,6 +52,11 @@ static void xml_handler_attr(XMLParser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen) { + (void)p; + (void)taglen; + (void)namelen; + (void)valuelen; + if(istag(tag, "outline")) { if(isattr(name, "text") || isattr(name, "title")) strlcpy(feedname, value, sizeof(feedname)); diff --git a/sfeed_web.c b/sfeed_web.c index 714c7b3..7ec9e83 100644 --- a/sfeed_web.c +++ b/sfeed_web.c @@ -12,6 +12,8 @@ static char feedlink[4096] = "", basehref[4096] = "", feedtype[256] = ""; static void xmltagstart(XMLParser *p, const char *tag, size_t taglen) { + (void)p; + isbase = islink = isfeedlink = 0; if(taglen == 4) { /* optimization */ if(!strncasecmp(tag, "base", taglen)) @@ -23,6 +25,11 @@ xmltagstart(XMLParser *p, const char *tag, size_t taglen) { static void xmltagstartparsed(XMLParser *p, const char *tag, size_t taglen, int isshort) { + (void)p; + (void)tag; + (void)taglen; + (void)isshort; + if(isfeedlink) { if(*feedtype) { fputs(feedtype, stdout); @@ -37,6 +44,10 @@ xmltagstartparsed(XMLParser *p, const char *tag, size_t taglen, int isshort) { static void xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen) { + (void)p; + (void)tag; + (void)taglen; + (void)valuelen; if(namelen != 4) /* optimization */ return; diff --git a/sfeed_xmlenc.c b/sfeed_xmlenc.c index 500064b..81d9795 100644 --- a/sfeed_xmlenc.c +++ b/sfeed_xmlenc.c @@ -10,6 +10,8 @@ static int isxmlpi = 0, tags = 0; static void xmltagstart(XMLParser *p, const char *tag, size_t taglen) { + (void)p; + /* optimization: try to find processing instruction at start */ if(tags > 3) exit(EXIT_FAILURE); @@ -19,13 +21,23 @@ xmltagstart(XMLParser *p, const char *tag, size_t taglen) { static void xmltagend(XMLParser *p, const char *tag, size_t taglen, int isshort) { + (void)p; + (void)tag; + (void)taglen; + (void)isshort; + isxmlpi = 0; } static void xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name, - size_t namelen, const char *value, size_t valuelen) + size_t namelen, const char *value, size_t valuelen) { + (void)p; + (void)tag; + (void)taglen; + (void)valuelen; + if(isxmlpi && (!strncasecmp(name, "encoding", namelen))) { if(*value) { /* output lowercase */ -- cgit v1.2.3