From 3d2748a623f51b895741a3cd2dff22ff154f29b1 Mon Sep 17 00:00:00 2001 From: werner Date: Tue, 4 Aug 2009 07:04:36 +0000 Subject: [PATCH] Valgrind and gcc -O: - stralloc_vprintf: used snprintf instead of vsnprintf. Oops ! - build_frames: didn't initialize "n" - added a few initializations to stop gcc from complaining git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5382 99fdad57-331a-0410-800a-d7fa5415bdb3 --- expr.c | 2 ++ gui.c | 2 +- inst.c | 3 ++- util.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/expr.c b/expr.c index ae9cd87..3eec5ae 100644 --- a/expr.c +++ b/expr.c @@ -182,6 +182,7 @@ static struct num compatible_sum(struct num *a, struct num *b) } res.type = a->type; res.exponent = a->exponent; + res.n = 0; /* keep gcc happy */ return res; } @@ -203,6 +204,7 @@ static struct num compatible_mult(struct num *a, struct num *b, } res.type = a->type; res.exponent = exponent; + res.n = 0; /* keep gcc happy */ return res; } diff --git a/gui.c b/gui.c index 31e77d2..daab3cb 100644 --- a/gui.c +++ b/gui.c @@ -576,7 +576,7 @@ static void build_frames(GtkWidget *vbox) { struct frame *frame; GtkWidget *tab, *label, *refs, *vars; - int n; + int n = 0; destroy_all_children(GTK_CONTAINER(vbox)); for (frame = frames; frame; frame = frame->next) diff --git a/inst.c b/inst.c index 2670247..993762f 100644 --- a/inst.c +++ b/inst.c @@ -126,7 +126,8 @@ int inst_select(const struct draw_ctx *ctx, struct coord pos) { enum inst_prio prio; struct inst *inst; - int best_dist, dist; + int best_dist = 0; /* keep gcc happy */ + int dist; deselect_outside(); edit_nothing(); diff --git a/util.c b/util.c index ec2b9d6..18204f5 100644 --- a/util.c +++ b/util.c @@ -29,7 +29,7 @@ char *stralloc_vprintf(const char *fmt, va_list ap) int n; va_copy(aq, ap); - n = snprintf(NULL, 0, fmt, aq); + n = vsnprintf(NULL, 0, fmt, aq); va_end(aq); buf = alloc_size(n+1); vsnprintf(buf, n+1, fmt, ap);