Skip to content

Commit

Permalink
Indicate that some variables are not read later in the function
Browse files Browse the repository at this point in the history
archive_read_format_tar_read_advance() is not part of libarchive (it's a
tarsnap-specific addition).

Reported by:	clang scan-build
  • Loading branch information
gperciva committed Jan 28, 2022
1 parent c7fc1f1 commit ba62ff9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions libarchive/archive_read_support_format_tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ archive_read_format_tar_read_advance(struct archive_read *a, off_t offset)
if (tar->entry_padding >= offset) {
tar->entry_padding -= offset;
offset = 0;
(void)offset; /* not used beyond this point. */
} else {
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
"read_advance beyond end of entry");
Expand Down
2 changes: 2 additions & 0 deletions tar/multitape/multitape_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ multitape_metadata_dec(struct tapemetadata * mdat, uint8_t * buf,
buflen -= 256;
p += 256;

(void)p; /* not used beyond this point. */

/* We should be at the end of the metadata now. */
if (buflen != 0)
goto bad2;
Expand Down
4 changes: 4 additions & 0 deletions tar/multitape/multitape_metaindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ multitape_metaindex_put(STORAGE_W * S, CHUNKS_W * C,
memcpy(p, mind->tindex, mind->tindexlen);
p += mind->tindexlen;

(void)p; /* 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))
Expand Down Expand Up @@ -273,6 +275,8 @@ multitape_metaindex_get(STORAGE_R * S, CHUNKS_S * C,
if (buflen != 0)
goto corrupt3;

(void)buf; /* not used beyond this point. */

/* Free metaindex buffer. */
free(mbuf);

Expand Down
2 changes: 2 additions & 0 deletions tests/valgrind/potential-memleaks.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pl_freebsd_getpwuid(void)
exit(1);
}

(void)pwd; /* not used beyond this point. */

/* POSIX says that we *shall not* free `pwd`. */
}

Expand Down

0 comments on commit ba62ff9

Please sign in to comment.