From ed14d0e0d1c21933413d51bf63811e3e892b080d Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 25 Jun 2012 06:29:37 -0700 Subject: [PATCH] Fix some new compiler warnings. 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 --- INSTALL | 2 +- parse.c | 2 +- vpatch.c | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index e106c89..a218830 100644 --- 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 15b06ae..e21dfb2 100644 --- 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; diff --git a/vpatch.c b/vpatch.c index 3a8d19a..0a02b19 100644 --- 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; -- 2.39.5