From 97018ace991d300a6ff75a1dcd1a69b4044f2b89 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Wed, 2 Nov 2022 14:47:04 -0600 Subject: [PATCH] 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 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- src/afs/afs_daemons.c | 4 ++++ src/kauth/kadatabase.c | 6 ++++-- src/ubik/recovery.c | 6 +++++- src/ubik/remote.c | 8 ++++---- src/vol/volume.c | 4 +++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index 5a64a61268..1cdae34fcd 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -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) diff --git a/src/kauth/kadatabase.c b/src/kauth/kadatabase.c index c63f643ef8..e08bb68295 100644 --- a/src/kauth/kadatabase.c +++ b/src/kauth/kadatabase.c @@ -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); diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index 2b837b4a2b..451dbbfc73 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -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); diff --git a/src/ubik/remote.c b/src/ubik/remote.c index 66d2318800..211045ef7d 100644 --- a/src/ubik/remote.c +++ b/src/ubik/remote.c @@ -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; diff --git a/src/vol/volume.c b/src/vol/volume.c index 420aa93db5..879b34e3ff 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -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; }