Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nitpicks from clang-scan #528

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/network/tsnetwork_sleep.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -41,7 +42,7 @@ network_sleep(struct timeval * timeo,
network_callback * callback, void * cookie)
{
struct sleeper s;
struct sleeper * sp = NULL; /* Silence bogus gcc warning. */
struct sleeper * sp = NULL; /* Silence bogus compiler warnings. */
size_t h;

/* Initialize array if required. */
Expand Down Expand Up @@ -83,6 +84,12 @@ network_sleep(struct timeval * timeo,
/* Append the record. */
if (sleepers_append(sleepers, &sp, 1))
goto err1;
} else {
/*-
* If (h != sleepers_getsize()), then sp was set in the
* earlier 'for' loop, but compilers don't realize it.
*/
assert(sp != NULL);
}

/* Register the timer event. */
Expand Down
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