From 6fd1db1a86e830b3758772a79f25c30080c4dd06 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sun, 25 Apr 2010 20:23:27 +0100 Subject: [PATCH] Demand Attach: Simplify __VVGC_entry_cl_add The __VVGC_entry_cl_add was giving an uninitialised variable warning for empty_idx, because it was using a separate variable, empty_found as a sentinel for when empty_idx was holding a real value. Simplify all of this by removing the sentinel, and making empty_idx being -1 mean 'not found', and a real value imply found. Change-Id: I6c485993df1ff8dfd27824234c811af998ff94fa Reviewed-on: http://gerrit.openafs.org/1833 Reviewed-by: Tom Keiser Reviewed-by: Alistair Ferguson Reviewed-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/vol/vg_cache.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/vol/vg_cache.c b/src/vol/vg_cache.c index f64384294..98f4366c1 100644 --- a/src/vol/vg_cache.c +++ b/src/vol/vg_cache.c @@ -261,12 +261,11 @@ static int _VVGC_entry_cl_add(VVGCache_entry_t * ent, VolumeId volid) { - int code = 0, i, empty_found, empty_idx; + int code = 0, i; + int empty_idx = -1; /* search table to avoid duplicates */ - for (i = 0, empty_found = 0; - i < VOL_VG_MAX_VOLS; - i++) { + for (i = 0; i < VOL_VG_MAX_VOLS; i++) { if (ent->children[i] == volid) { ViceLog(1, ("VVGC_entry_cl_add: tried to add duplicate vol " "%lu to VG %lu\n", @@ -274,16 +273,15 @@ _VVGC_entry_cl_add(VVGCache_entry_t * ent, afs_printable_uint32_lu(ent->rw))); goto done; } - if (!empty_found && !ent->children[i]) { + if (empty_idx == -1 && !ent->children[i]) { empty_idx = i; - empty_found = 1; /* don't break; make sure we go through all children so we don't * add a duplicate entry */ } } /* verify table isn't full */ - if (!empty_found) { + if (empty_idx == -1) { code = -1; ViceLog(0, ("VVGC_entry_cl_add: tried to add vol %lu to VG %lu, but VG " "is full\n", afs_printable_uint32_lu(volid), -- 2.39.5