From f21741506b1c4db16cebe79cfd310d97dc061466 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Wed, 26 Jan 2022 20:02:17 -0800 Subject: [PATCH] Indicate that some variables are not read later in the function Reported by: clang-scan --- tar/multitape/multitape_metadata.c | 2 ++ tar/multitape/multitape_metaindex.c | 4 ++++ tests/valgrind/potential-memleaks.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/tar/multitape/multitape_metadata.c b/tar/multitape/multitape_metadata.c index e5469c2b..007dd292 100644 --- a/tar/multitape/multitape_metadata.c +++ b/tar/multitape/multitape_metadata.c @@ -269,6 +269,8 @@ multitape_metadata_dec(struct tapemetadata * mdat, uint8_t * buf, buflen -= 256; p += 256; + (void)p; /* p is not used beyond this point. */ + /* We should be at the end of the metadata now. */ if (buflen != 0) goto bad2; diff --git a/tar/multitape/multitape_metaindex.c b/tar/multitape/multitape_metaindex.c index 2e2a1937..bf59476a 100644 --- a/tar/multitape/multitape_metaindex.c +++ b/tar/multitape/multitape_metaindex.c @@ -106,6 +106,8 @@ multitape_metaindex_put(STORAGE_W * S, CHUNKS_W * C, memcpy(p, mind->tindex, mind->tindexlen); p += mind->tindexlen; + (void)p; /* p is not used beyond this point. */ + /* Compute hash of tape name. */ if (crypto_hash_data(CRYPTO_KEY_HMAC_NAME, (uint8_t *)mdat->name, strlen(mdat->name), hbuf)) @@ -273,6 +275,8 @@ multitape_metaindex_get(STORAGE_R * S, CHUNKS_S * C, if (buflen != 0) goto corrupt3; + (void)buf; /* buf is not used beyond this point. */ + /* Free metaindex buffer. */ free(mbuf); diff --git a/tests/valgrind/potential-memleaks.c b/tests/valgrind/potential-memleaks.c index 7c5c9440..d730d1c3 100644 --- a/tests/valgrind/potential-memleaks.c +++ b/tests/valgrind/potential-memleaks.c @@ -56,6 +56,8 @@ pl_freebsd_getpwuid(void) exit(1); } + (void)pwd; /* pwd is not used beyond this point. */ + /* POSIX says that we *shall not* free `pwd`. */ }