]> git.neil.brown.name Git - wiggle.git/commitdiff
Ask for more warnings and fix some.
authorNeil Brown <neilb@suse.de>
Mon, 22 Aug 2011 04:28:20 +0000 (14:28 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 22 Aug 2011 04:28:20 +0000 (14:28 +1000)
In particular we were using strncmp without including string.h -
because memory.h automatically includes it..

Reported-by: Oliver Kiddle <oliver@kiddle.eu>
Signed-off-by: NeilBrown <neilb@suse.de>
Makefile
diff.c
merge.c
vpatch.c
wiggle.c
wiggle.h

index 85548ef898b8a5767dd03ef2e98aed7eff5ac1d0..a53e19c73f53e6adb4823b695101ca3b3480afd5 100644 (file)
--- 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 8b9ffed5628c8969732e6bda01c77254fd28c41c..013239c1a4fa017495683175ebf11d75e4c42403 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -42,7 +42,6 @@
 
 #include       <malloc.h>
 #include       "wiggle.h"
-#include       <string.h>
 #include       <stdlib.h>
 
 
diff --git a/merge.c b/merge.c
index 63a7d4701ee1272396a03eacf8ecb2f6870ae6d3..40d7da77d65e84a245d996b6a1a51693f0b93af7 100644 (file)
--- 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",
index 9f62baa2731e5fc310a4fe9cb79cd072c16453f4..0bf4884b4b8ae891f895ba9883572c0cd795a404 100644 (file)
--- a/vpatch.c
+++ b/vpatch.c
 
 #include "wiggle.h"
 #include <malloc.h>
-#include <string.h>
 #include <curses.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <fcntl.h>
 
-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;
index b3ca73924b98bf6f0e198fb6815706c327c3a285..4938677ce709a2f55a6f149dba0cdfec1ff38a60 100644 (file)
--- a/wiggle.c
+++ b/wiggle.c
@@ -75,7 +75,6 @@
 
 #include       "wiggle.h"
 #include       <errno.h>
-#include       <string.h>
 #include       <fcntl.h>
 #include       <unistd.h>
 #include       <stdlib.h>
index 15a75b5d0c3124570f761ce7f4d9856af052dfcd..76d42134665c1d3ac03fb1b657c07a90310c85f1 100644 (file)
--- a/wiggle.h
+++ b/wiggle.h
@@ -22,8 +22,9 @@
  *    Email: <neilb@suse.de>
  */
 
-#include <stdio.h>
-#include <memory.h>
+#include       <stdio.h>
+#include       <string.h>
+#include       <memory.h>
 #include       <getopt.h>
 
 struct stream {