]> git.neil.brown.name Git - wiggle.git/commitdiff
Fix some new compiler warnings.
authorChris Peterson <cpeterso@cpeterso.com>
Mon, 25 Jun 2012 13:29:37 +0000 (06:29 -0700)
committerNeilBrown <neilb@suse.de>
Tue, 26 Jun 2012 01:51:03 +0000 (11:51 +1000)
hi Neil, I pulled wiggle's latest head from git and tried to compile on Mac
OS X. I ran into some problems when I tried to compile with -O3 without
-ggdb.

gcc -Werror treated some uninitialized variable warnings as errors. Some of
the warnings look like real bugs, but many were false positives. Compiling
with -O3 and -ggdb makes all the warnings "go away." :)

I've attached a patch to fix the following valid warnings:

cc1: warnings being treated as errors
parse.c: In function `parse_patch':
parse.c:268: warning: `c' may be used uninitialized in this function

vpatch.c: In function `next_melmnt':
vpatch.c:418: warning: `e.hash' may be used uninitialized in this function

vpatch.c: In function `prev_melmnt':
vpatch.c:472: warning: `e.hash' may be used uninitialized in this function

vpatch.c: In function `draw_mside':
vpatch.c:838: warning: `tag_attr' may be used uninitialized in this function
vpatch.c:837: warning: `tag' may be used uninitialized in this function

vpatch.c:1334: warning: `e' may be used uninitialized in this function

Signed-off-by: NeilBrown <neilb@suse.de>
INSTALL
parse.c
vpatch.c

diff --git a/INSTALL b/INSTALL
index e106c89288e189bf3fe94f53fff85fd252bd51ea..a218830afc5ae70c22e951a266de70c9d65b8dfd 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -7,5 +7,5 @@ This will install /usr/bin/wiggle and /usr/share/man/man1/wiggle.1
 
 You might like to inspect the Makefile and change
    OptDbg=-ggdb
-to something that will compile faster code on your compter, such as
+to something that will compile faster code on your computer, such as
    OptDbg=-O3 -march=pentium2
diff --git a/parse.c b/parse.c
index 15b06aeeec5619c91b5db1779e1c84d61561c215..e21dfb24af48c0780d7a52d5bd62d5a617d6c4f6 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -265,7 +265,7 @@ struct plist *parse_patch(FILE *f, FILE *of, int *np)
                char *target = "\n+++ ";
                char *target2 = "\n--- ";
                char *pos = target;
-               int c;
+               int c = EOF;
                char name[1024];
                unsigned start, end;
 
index 3a8d19a6c1cfecf8f4bfc69fcaaf74b43b8e5398..0a02b1912a4963cb9059ee7627a6cc4d8224a34c 100644 (file)
--- a/vpatch.c
+++ b/vpatch.c
@@ -416,7 +416,7 @@ static struct elmnt next_melmnt(struct mp *pos,
        }
        if (pos->m == -1 || m[pos->m].type == End) {
                struct elmnt e;
-               e.start = NULL; e.len = 0;
+               e.start = NULL; e.hash = 0; e.len = 0;
                return e;
        }
        switch (pos->s) {
@@ -470,7 +470,7 @@ static struct elmnt prev_melmnt(struct mp *pos,
        }
        if (pos->m < 0) {
                struct elmnt e;
-               e.start = NULL; e.len = 0;
+               e.start = NULL; e.hash = 0; e.len = 0;
                return e;
        }
        switch (pos->s) {
@@ -838,6 +838,7 @@ static void draw_mside(int mode, int row, int offset, int start, int cols,
        unsigned int tag_attr;
 
        switch (pos.state) {
+       default: /* keep compiler happy */
        case 0: /* unchanged line */
                tag = ' ';
                tag_attr = A_NORMAL;
@@ -1333,6 +1334,7 @@ static void merge_window(struct plist *p, FILE *f, int reverse)
                        char *e, e2[7];
                        int i;
                        switch (vpos.p.s) {
+                       default: /* keep compiler happy */
                        case 0:
                                e = fm.list[ci.merger[vpos.p.m].a + vpos.p.o].start;
                                break;