From d3ccaa7cb90422ddfec5ae8af63aaad711a6f9e5 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 9 Jun 2011 11:56:02 +0200 Subject: [PATCH] [buddy] Remove some valgrind warnings about uninitialized memory when BddCache_lookup return an entry from a Not operation. * src/bddop.c (apply_rec, simplify_rec): When checking the cache entry, always check entry->a and entry->c before checking entry->b, because the "not_rec()" function does not initialize the latter. --- buddy/ChangeLog | 10 ++++++++++ buddy/src/bddop.c | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/buddy/ChangeLog b/buddy/ChangeLog index 74d15a95d..2dde4925f 100644 --- a/buddy/ChangeLog +++ b/buddy/ChangeLog @@ -1,3 +1,13 @@ +2011-06-09 Alexandre Duret-Lutz + + Remove some valgrind warnings about uninitialized memory when + BddCache_lookup return an entry from a Not operation. + + * src/bddop.c (apply_rec, simplify_rec): When checking the cache + entry, always check entry->a and entry->c before checking + entry->b, because the "not_rec()" function does not initialize + the latter. + 2011-06-07 Alexandre Duret-Lutz * examples/cmilner/cmilner.c (A, transitions, initial_state) diff --git a/buddy/src/bddop.c b/buddy/src/bddop.c index e28cc4f60..71711accd 100644 --- a/buddy/src/bddop.c +++ b/buddy/src/bddop.c @@ -619,7 +619,8 @@ static BDD apply_rec(BDD l, BDD r) { entry = BddCache_lookup(&applycache, APPLYHASH(l,r,applyop)); - if (entry->a == l && entry->b == r && entry->c == applyop) + // Check entry->c last, because not_rec() does not initialize it. + if (entry->a == l && entry->c == applyop && entry->b == r) { #ifdef CACHESTATS bddcachestats.opHit++; @@ -1649,7 +1650,8 @@ static BDD simplify_rec(BDD f, BDD d) entry = BddCache_lookup(&applycache, APPLYHASH(f,d,bddop_simplify)); - if (entry->a == f && entry->b == d && entry->c == bddop_simplify) + // Check entry->c last, because not_rec() does not initialize it. + if (entry->a == f && entry->c == bddop_simplify && entry->b == d) { #ifdef CACHESTATS bddcachestats.opHit++;