clang-16: Fix conditionally unused-but-set variables

clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.

   remote.c:485:15: error: variable 'pass' set but not used
       [-Werror,-Wunused-but-set-variable]
     afs_int32 pass;
              ^
These variables are actually used in specific cases depending on
build configuration (e.g. AFS_PTHREAD_ENV, etc.).

Relocate these variables so they are fully defined or referenced within
preprocessor '#if' blocks.

Change-Id: I900a192ec781be4ab4453769e1d8f0cc48fe5757
Reviewed-on: https://gerrit.openafs.org/15177
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Cheyenne Wills 2022-11-02 14:47:04 -06:00 committed by Benjamin Kaduk
parent 05eb420829
commit 97018ace99
5 changed files with 20 additions and 8 deletions

View File

@ -1046,7 +1046,9 @@ afs_BackgroundDaemon(void)
{
struct brequest *tb;
int i, foundAny;
#ifdef AFS_NEW_BKG
int n_processed = 0;
#endif
AFS_STATCNT(afs_BackgroundDaemon);
/* initialize subsystem */
@ -1123,7 +1125,9 @@ afs_BackgroundDaemon(void)
tb->flags |= BSTARTED;
ReleaseWriteLock(&afs_xbrs);
foundAny = 1;
#ifdef AFS_NEW_BKG
n_processed++;
#endif
afs_Trace1(afs_iclSetp, CM_TRACE_BKG1, ICL_TYPE_INT32,
tb->opcode);
if (tb->opcode == BOP_FETCH)

View File

@ -413,9 +413,10 @@ ka_NewKey(struct ubik_trans *tt, afs_int32 tentryaddr,
int code, i;
Date now = time(0);
afs_int32 newkeyver; /* new key version number */
afs_int32 newtotalkeyentries = 0, oldtotalkeyentries = 0, keyentries;
afs_int32 newtotalkeyentries = 0, keyentries;
int addednewkey = 0, modified;
#ifdef AUTH_DBM_LOG
afs_int32 oldtotalkeyentries = 0;
int foundcurrentkey = 0;
#endif
@ -451,11 +452,12 @@ ka_NewKey(struct ubik_trans *tt, afs_int32 tentryaddr,
keyentries = 0; /* Number of valid key entries in the block */
for (i = 0; i < NOLDKEYS; i++) {
/* foreachkey */
#ifdef AUTH_DBM_LOG
/* Keep count of number of entries found */
if (okeys.keys[i].superseded != 0) {
oldtotalkeyentries++;
}
#endif
/* If we find the entry that is not superseded, then supersede it */
if (ntohl(okeys.keys[i].superseded) == NEVERDATE) {
okeys.keys[i].superseded = htonl(now);

View File

@ -470,7 +470,9 @@ urecovery_Interact(void *dummy)
char hoststr[16];
char pbuffer[1028];
int fd = -1;
#ifndef AFS_PTHREAD_ENV
afs_int32 pass;
#endif
int first;
memset(pbuffer, 0, sizeof(pbuffer));
@ -663,12 +665,15 @@ urecovery_Interact(void *dummy)
goto FetchEndCall;
}
#ifndef AFS_PTHREAD_ENV
pass = 0;
#endif
while (length > 0) {
tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
#ifndef AFS_PTHREAD_ENV
if (pass % 4 == 0)
IOMGR_Poll();
pass++;
#endif
nbytes = rx_Read(rxcall, tbuffer, tlen);
if (nbytes != tlen) {
@ -678,7 +683,6 @@ urecovery_Interact(void *dummy)
goto FetchEndCall;
}
nbytes = write(fd, tbuffer, tlen);
pass++;
if (nbytes != tlen) {
code = UIOERROR;
close(fd);

View File

@ -482,8 +482,9 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
char pbuffer[1028];
int fd = -1;
afs_int32 epoch = 0;
afs_int32 pass;
#if !defined(AFS_PTHREAD_ENV)
afs_int32 pass = 0;
#endif
/* send the file back to the requester */
dbase = ubik_dbase;
@ -543,7 +544,6 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
close(fd);
goto failed_locked;
}
pass = 0;
memcpy(&ubik_dbase->version, &tversion, sizeof(struct ubik_version));
UBIK_VERSION_UNLOCK;
while (length > 0) {
@ -551,6 +551,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
#if !defined(AFS_PTHREAD_ENV)
if (pass % 4 == 0)
IOMGR_Poll();
pass++;
#endif
code = rx_Read(rxcall, tbuffer, tlen);
if (code != tlen) {
@ -560,7 +561,6 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
goto failed;
}
code = write(fd, tbuffer, tlen);
pass++;
if (code != tlen) {
ViceLog(0, ("write failed tlen=%d, error=%d\n", tlen, code));
code = UIOERROR;

View File

@ -8510,9 +8510,9 @@ DeleteVolumeFromHashTable(Volume * vp)
Volume *
VLookupVolume_r(Error * ec, VolumeId volumeId, Volume * hint)
{
int looks = 0;
Volume * vp, *np;
#ifdef AFS_DEMAND_ATTACH_FS
int looks = 0;
Volume *pp;
#endif
VolumeHashChainHead * head;
@ -8537,7 +8537,9 @@ VLookupVolume_r(Error * ec, VolumeId volumeId, Volume * hint)
/* search the chain for this volume id */
for(queue_Scan(head, vp, np, Volume)) {
#ifdef AFS_DEMAND_ATTACH_FS
looks++;
#endif
if (vp->hashid == volumeId) {
break;
}