From: Simon Wilkinson Date: Sun, 24 Feb 2013 12:43:27 +0000 (+0000) Subject: budb: Simplify scanHashTableBlock X-Git-Tag: upstream/1.8.0_pre1^2~1429 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2a2cae72d653fbfdada7dddd4b7e5d8aeedea2ee;p=packages%2Fo%2Fopenafs.git budb: Simplify scanHashTableBlock We don't need to maintain two copies (entryAddr and nextEntryAddr) of the entry address - rework the while loop so we just use one, and make clang a little happier Caught by clang-analyzer Change-Id: I6f5d76e114ad09a4fd3fc36b4d64f63daa9e1e78 Reviewed-on: http://gerrit.openafs.org/9251 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear Tested-by: BuildBot --- diff --git a/src/budb/db_hash.c b/src/budb/db_hash.c index 59a984a7d..e51d7a35e 100644 --- a/src/budb/db_hash.c +++ b/src/budb/db_hash.c @@ -1107,7 +1107,7 @@ scanHashTableBlock(struct ubik_trans *ut, int entrySize; /* hashed entry size */ char entry[sizeof(struct block)]; - dbadr entryAddr, nextEntryAddr; + dbadr entryAddr; int i; @@ -1119,19 +1119,17 @@ scanHashTableBlock(struct ubik_trans *ut, */ for (i = 0; (i < nHTBuckets) && (index < length); i++, index++) { /*f */ - entryAddr = 0; - nextEntryAddr = ntohl(htBlockPtr->bucket[i]); + entryAddr = ntohl(htBlockPtr->bucket[i]); /* if this is the old hash table, all entries below the progress mark * should have been moved to the new hash table */ - if (old && (index < mhtPtr->progress) && nextEntryAddr) + if (old && (index < mhtPtr->progress) && entryAddr) return BUDB_INTERNALERROR; /* now walk down the chain of each bucket */ - while (nextEntryAddr) { /*w */ + while (entryAddr) { /*w */ - entryAddr = nextEntryAddr; if (dbread(ut, entryAddr, &entry[0], entrySize)) return (BUDB_INTERNALERROR); @@ -1139,7 +1137,7 @@ scanHashTableBlock(struct ubik_trans *ut, (*operationFn) (entryAddr, &entry[0], rockPtr); } - nextEntryAddr = + entryAddr = ntohl(*((dbadr *) (entry + mhtPtr->threadOffset))); } /*w */