From c4d6869cc870fb1a100658aa330d6b6df4ba52d7 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 22 Aug 2011 14:28:20 +1000 Subject: [PATCH] Ask for more warnings and fix some. In particular we were using strncmp without including string.h - because memory.h automatically includes it.. Reported-by: Oliver Kiddle Signed-off-by: NeilBrown --- Makefile | 2 +- diff.c | 1 - merge.c | 7 +++---- vpatch.c | 30 +++++++++++++++++++----------- wiggle.c | 1 - wiggle.h | 5 +++-- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 85548ef..a53e19c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ #OptDbg=-O3 #OptDbg=-O3 -march=pentium2 OptDbg=-ggdb -CFLAGS=$(OptDbg) -Wall -Werror +CFLAGS=$(OptDbg) -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter # STRIP = -s INSTALL = /usr/bin/install diff --git a/diff.c b/diff.c index 8b9ffed..013239c 100644 --- a/diff.c +++ b/diff.c @@ -42,7 +42,6 @@ #include #include "wiggle.h" -#include #include diff --git a/merge.c b/merge.c index 63a7d47..40d7da7 100644 --- a/merge.c +++ b/merge.c @@ -617,8 +617,7 @@ static int end_of_file(struct point p, struct csl *c1, struct csl *c2) } static int next_conflict(struct point here, struct csl *start_c1, struct csl *start_c2, - struct point *start, struct point *end, - struct file *a, struct file *b, struct file *c) + struct point *start, struct point *end) { /* We want to find the start and end of the 'next' conflict. * There may not be another conflict, in which case set start and @@ -847,10 +846,10 @@ struct ci print_merge(FILE *out, struct file *a, struct file *b, struct file *c, retreat(c1,c2, &start_last); while (!end_of_file(end_last, c1, c2)) { - next_conflict(end_last, c1, c2, &start_next, &end_next, a, b, c); + next_conflict(end_last, c1, c2, &start_next, &end_next); while (already_applied(c1,c2,start_next,end_next,a,b,c)) { rv.ignored++; - next_conflict(end_next, c1,c2,&start_next,&end_next,a,b,c); + next_conflict(end_next, c1,c2,&start_next,&end_next); } #if 0 printf("start %d %d (%d,%d) end %d %d (%d,%d)\n", diff --git a/vpatch.c b/vpatch.c index 9f62baa..0bf4884 100644 --- a/vpatch.c +++ b/vpatch.c @@ -40,14 +40,13 @@ #include "wiggle.h" #include -#include #include #include #include #include #include -static void term_init(); +static void term_init(void); #define assert(x) do { if (!(x)) abort(); } while (0) @@ -74,7 +73,8 @@ static struct stream load_segment(FILE *f, unsigned int start, unsigned int end); /* global attributes */ -int a_delete, a_added, a_common, a_sep, a_void, a_unmatched, a_extra, a_already; +unsigned int a_delete, a_added, a_common, a_sep, a_void, + a_unmatched, a_extra, a_already; /****************************************************************** * Help window @@ -449,7 +449,8 @@ static struct elmnt prev_melmnt(struct mp *pos, */ static int visible(int mode, enum mergetype type, int stream) { - if (mode == 0) return -1; + if (mode == 0) + return -1; /* mode can be any combination of ORIG RESULT BEFORE AFTER */ switch(type) { case End: /* The END is always visible */ @@ -643,7 +644,7 @@ static void prev_mline(struct mpos *pos, struct file fm, struct file fb, } /* blank a whole row of display */ -static void blank(int row, int start, int cols, int attr) +static void blank(int row, int start, int cols, unsigned int attr) { (void)attrset(attr); move(row,start); @@ -786,7 +787,10 @@ static void draw_mside(int mode, int row, int offset, int start, int cols, mvaddstr(row, col-start+offset, b); col += strlen(b); } - blank(row, col-start+offset, start+cols-col, e.start?visible(mode, m[pos.p.m].type, pos.p.s):A_NORMAL ); + blank(row, col-start+offset, start+cols-col, + e.start + ?(unsigned)visible(mode, m[pos.p.m].type, pos.p.s) + :A_NORMAL ); return; } if (visible(mode, m[pos.p.m].type, pos.p.s) == -1) { @@ -1048,14 +1052,15 @@ static void merge_window(struct plist *p, FILE *f, int reverse) int meta = 0, tmeta; int num= -1, tnum; char search[80]; - int searchlen = 0; + unsigned int searchlen = 0; int search_notfound = 0; int searchdir = 0; struct search_anchor { struct search_anchor *next; struct mpos pos; int notfound; - int row, col, searchlen; + int row, col; + unsigned int searchlen; } *anchor = NULL; if (f == NULL) { @@ -1188,7 +1193,10 @@ static void merge_window(struct plist *p, FILE *f, int reverse) mvaddstr(0, cols - strlen(lbuf) - 1, lbuf); } /* Always refresh the line */ - while (start > target) { start -= 8; refresh = 1;} + while (start > target) { + start -= 8; + refresh = 1; + } if (start < 0) start = 0; retry: draw_mline(mode, row, start, cols, fm,fb,fa,ci.merger, @@ -1731,7 +1739,7 @@ static struct stream load_segment(FILE *f, s.body = malloc(s.len); if (s.body) { fseek(f, start, 0); - if (fread(s.body, 1, s.len, f) != s.len) { + if (fread(s.body, 1, s.len, f) != (size_t)s.len) { free(s.body); s.body = NULL; } @@ -2229,7 +2237,7 @@ static void catch(int sig) exit(2); } -static void term_init() +static void term_init(void) { static int init_done = 0; diff --git a/wiggle.c b/wiggle.c index b3ca739..4938677 100644 --- a/wiggle.c +++ b/wiggle.c @@ -75,7 +75,6 @@ #include "wiggle.h" #include -#include #include #include #include diff --git a/wiggle.h b/wiggle.h index 15a75b5..76d4213 100644 --- a/wiggle.h +++ b/wiggle.h @@ -22,8 +22,9 @@ * Email: */ -#include -#include +#include +#include +#include #include struct stream { -- 2.39.5