From f554a6b65fd09f71243af94691c48b3d4d2b1132 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Mon, 5 Sep 2011 01:22:03 +0000 Subject: [PATCH] Fix "may be used uninitialized" warnings in db2 code, even though all such cases appear to be safe. This will permit making uninitialized-variable messages fatal. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25147 dc483132-0cff-0310-8789-dd5450dbe970 --- src/plugins/kdb/db2/libdb2/btree/bt_delete.c | 2 +- src/plugins/kdb/db2/libdb2/btree/bt_search.c | 4 ++-- src/plugins/kdb/db2/libdb2/btree/bt_seq.c | 4 ++-- src/plugins/kdb/db2/libdb2/btree/bt_split.c | 7 ++++--- src/plugins/kdb/db2/libdb2/hash/hash_page.c | 1 + src/plugins/kdb/db2/libdb2/recno/rec_open.c | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/kdb/db2/libdb2/btree/bt_delete.c b/src/plugins/kdb/db2/libdb2/btree/bt_delete.c index 02ae2e9be..4133aa3f0 100644 --- a/src/plugins/kdb/db2/libdb2/btree/bt_delete.c +++ b/src/plugins/kdb/db2/libdb2/btree/bt_delete.c @@ -150,7 +150,7 @@ __bt_stkacq(t, hp, c) EPG *e; EPGNO *parent; PAGE *h; - indx_t idx; + indx_t idx = 0; db_pgno_t pgno; recno_t nextpg, prevpg; int exact, level; diff --git a/src/plugins/kdb/db2/libdb2/btree/bt_search.c b/src/plugins/kdb/db2/libdb2/btree/bt_search.c index de7ab126f..1f4f7160d 100644 --- a/src/plugins/kdb/db2/libdb2/btree/bt_search.c +++ b/src/plugins/kdb/db2/libdb2/btree/bt_search.c @@ -157,7 +157,7 @@ __bt_snext(t, h, key, exactp) BINTERNAL *bi; EPG e; EPGNO *parent; - indx_t idx; + indx_t idx = 0; db_pgno_t pgno; int level; @@ -237,7 +237,7 @@ __bt_sprev(t, h, key, exactp) BINTERNAL *bi; EPG e; EPGNO *parent; - indx_t idx; + indx_t idx = 0; db_pgno_t pgno; int level; diff --git a/src/plugins/kdb/db2/libdb2/btree/bt_seq.c b/src/plugins/kdb/db2/libdb2/btree/bt_seq.c index 6124f968b..5707cab9b 100644 --- a/src/plugins/kdb/db2/libdb2/btree/bt_seq.c +++ b/src/plugins/kdb/db2/libdb2/btree/bt_seq.c @@ -269,7 +269,7 @@ __bt_seqadv(t, ep, flags) { CURSOR *c; PAGE *h; - indx_t idx; + indx_t idx = 0; db_pgno_t pg; int exact, rval; @@ -818,7 +818,7 @@ bt_rseqadv(t, ep, rc, flags) { CURSOR *c; PAGE *h; - indx_t idx; + indx_t idx = 0; db_pgno_t pg; int status; EPGNO *e; diff --git a/src/plugins/kdb/db2/libdb2/btree/bt_split.c b/src/plugins/kdb/db2/libdb2/btree/bt_split.c index 9b2708e76..2460aa54f 100644 --- a/src/plugins/kdb/db2/libdb2/btree/bt_split.c +++ b/src/plugins/kdb/db2/libdb2/btree/bt_split.c @@ -87,14 +87,14 @@ __bt_split(t, sp, key, data, flags, ilen, argskip) size_t ilen; u_int32_t argskip; { - BINTERNAL *bi; - BLEAF *bl, *tbl; + BINTERNAL *bi = NULL; + BLEAF *bl = NULL, *tbl; DBT a, b; EPGNO *parent; PAGE *h, *l, *r, *lchild, *rchild; indx_t nxtindex; u_int16_t skip; - u_int32_t n, nbytes, nksize; + u_int32_t n, nbytes, nksize = 0; int parentsplit; char *dest; @@ -637,6 +637,7 @@ bt_psplit(t, h, l, r, pskip, ilen) full = t->bt_psize - BTDATAOFF; half = full / 2; used = 0; + src = NULL; /* silence gcc "uninitialized" warning */ for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { if (skip == off) { nbytes = ilen; diff --git a/src/plugins/kdb/db2/libdb2/hash/hash_page.c b/src/plugins/kdb/db2/libdb2/hash/hash_page.c index 5841e92b5..86ba7ba28 100644 --- a/src/plugins/kdb/db2/libdb2/hash/hash_page.c +++ b/src/plugins/kdb/db2/libdb2/hash/hash_page.c @@ -1093,6 +1093,7 @@ overflow_page(hashp) * before being set, however, this loop will ALWAYS get executed * at least once, so freep is guaranteed to be set. */ + freep = NULL; first_page = hashp->hdr.last_freed >> (hashp->hdr.bshift + BYTE_SHIFT); for (i = first_page; i <= free_page; i++) { if (!(freep = fetch_bitmap(hashp, i))) diff --git a/src/plugins/kdb/db2/libdb2/recno/rec_open.c b/src/plugins/kdb/db2/libdb2/recno/rec_open.c index cb971ed3d..d8b26e701 100644 --- a/src/plugins/kdb/db2/libdb2/recno/rec_open.c +++ b/src/plugins/kdb/db2/libdb2/recno/rec_open.c @@ -65,7 +65,7 @@ __rec_open(fname, flags, mode, openinfo, dflags) DB *dbp; PAGE *h; struct stat sb; - int rfd, sverrno; + int rfd = -1, sverrno; /* Open the user's file -- if this fails, we're done. */ if (fname != NULL && (rfd = open(fname, flags | O_BINARY, mode)) < 0) -- 2.26.2