From: Simon Wilkinson Date: Fri, 22 Feb 2013 16:54:17 +0000 (+0000) Subject: Unix CM: Fix byte accounting for storebehind X-Git-Tag: upstream/1.8.0_pre1^2~1471 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5acb1a0f323a6692cca66ee3aa4c7e5f1a0f24f2;p=packages%2Fo%2Fopenafs.git Unix CM: Fix byte accounting for storebehind In the current version of CacheStoreDCaches, the stored variable is maintained within the for loop that iterates over the chunk list. This means that it is reset to 0 each time we handle a new chunk. However, this means that our progress is no longer accurately tracked, as (bytes - stored) no longer gives the number of bytes which remain to be transfered. In fact, as stored is zeroed with each loop iteration, (bytes - stored) == bytes. This means that store behind is no longer activated according to the users settings. Prior to commit 334114ac58b0039ae90d7e29fa2f019fe068bd79, the stored variable was maintained within the outer, function, scope. Just move it back there to restore the previous behaviour. Caught by clang-analyzer Change-Id: I248ed81f1331f4d3d4ed2e1206acebb0a8200762 Reviewed-on: http://gerrit.openafs.org/9237 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/afs_fetchstore.c b/src/afs/afs_fetchstore.c index 119807354..35c357ac8 100644 --- a/src/afs/afs_fetchstore.c +++ b/src/afs/afs_fetchstore.c @@ -465,6 +465,7 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist, { int *shouldwake = NULL; unsigned int i; + int stored = 0; afs_int32 code = 0; afs_size_t bytesXferred; @@ -476,7 +477,6 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist, osi_Assert(nchunks != 0); for (i = 0; i < nchunks && !code; i++) { - int stored = 0; struct dcache *tdc = dclist[i]; afs_int32 size;