aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2022-05-25 18:45:42 -0400
committerCameron Katri <me@cameronkatri.com>2022-05-25 18:45:42 -0400
commit31e664a3e50696bf19ddf27b85ad2e766967d41e (patch)
tree0e94dfcacae7f4fb9182ca426e3257fee54ac627
parent3dbb2ce2ea8b12867db0e24d4bd6c7c6501f5d5d (diff)
downloadtrustcache-31e664a3e50696bf19ddf27b85ad2e766967d41e.tar.gz
trustcache-31e664a3e50696bf19ddf27b85ad2e766967d41e.tar.zst
trustcache-31e664a3e50696bf19ddf27b85ad2e766967d41e.zip
Fix compilation with -Wall -Wextra -Werror
-rw-r--r--cache_from_tree.c2
-rw-r--r--machoparse/cdhash.c17
2 files changed, 8 insertions, 11 deletions
diff --git a/cache_from_tree.c b/cache_from_tree.c
index 90cafda..1f45e2a 100644
--- a/cache_from_tree.c
+++ b/cache_from_tree.c
@@ -36,7 +36,7 @@
static struct trust_cache cache = {};
static int
-tccallback(const char *path, const struct stat *sb, int typeflag, struct FTW *ftw)
+tccallback(const char *path, const struct stat *sb, __attribute__((unused)) int typeflag, __attribute__((unused)) struct FTW *ftw)
{
if (!S_ISREG(sb->st_mode))
return 0;
diff --git a/machoparse/cdhash.c b/machoparse/cdhash.c
index 5ccd3aa..a8a11f0 100644
--- a/machoparse/cdhash.c
+++ b/machoparse/cdhash.c
@@ -105,7 +105,7 @@ macho_identify(const struct mach_header_64 *mh, const struct mach_header *mh32,
// Get the next load command in a Mach-O file.
static const void *
-macho_next_load_command(const struct mach_header_64 *mh, const struct mach_header *mh32, size_t size, const void *lc) {
+macho_next_load_command(const struct mach_header_64 *mh, const struct mach_header *mh32, const void *lc) {
const struct load_command *next = lc;
if (next == NULL) {
@@ -130,11 +130,10 @@ macho_next_load_command(const struct mach_header_64 *mh, const struct mach_heade
// Find the next load command in a Mach-O file matching the given type.
static const void *
-macho_find_load_command(const struct mach_header_64 *mh, const struct mach_header *mh32, size_t size,
- uint32_t command, const void *lc) {
+macho_find_load_command(const struct mach_header_64 *mh, const struct mach_header *mh32, uint32_t command, const void *lc) {
const struct load_command *loadcmd = lc;
for (;;) {
- loadcmd = macho_next_load_command(mh, mh32, size, loadcmd);
+ loadcmd = macho_next_load_command(mh, mh32, loadcmd);
if (loadcmd == NULL || swap(mh, mh32, loadcmd->cmd) == command) {
return loadcmd;
}
@@ -221,7 +220,7 @@ cdhash_sha384(CS_CodeDirectory *cd, size_t length, void *cdhash) {
// Compute the cdhash from a CS_CodeDirectory.
static bool
-cs_codedirectory_cdhash(CS_CodeDirectory *cd, size_t size, struct hashes *cdhash) {
+cs_codedirectory_cdhash(CS_CodeDirectory *cd, struct hashes *cdhash) {
size_t length = be32toh(cd->length);
switch (cd->hashType) {
case CS_HASHTYPE_SHA1:
@@ -270,7 +269,6 @@ cs_superblob_cdhash(CS_SuperBlob *sb, size_t size, void *cdhash) {
// Iterate through each index searching for the best code directory.
CS_CodeDirectory *best_cd = NULL;
unsigned best_cd_rank = 0;
- size_t best_cd_size = 0;
uint32_t count = be32toh(sb->count);
for (size_t i = 0; i < count; i++) {
CS_BlobIndex *index = &sb->index[i];
@@ -295,7 +293,6 @@ cs_superblob_cdhash(CS_SuperBlob *sb, size_t size, void *cdhash) {
if (cd_rank > best_cd_rank) {
best_cd = cd;
best_cd_rank = cd_rank;
- best_cd_size = cd_size;
}
}
}
@@ -305,7 +302,7 @@ cs_superblob_cdhash(CS_SuperBlob *sb, size_t size, void *cdhash) {
return false;
}
// Hash the code directory.
- return cs_codedirectory_cdhash(best_cd, best_cd_size, cdhash);
+ return cs_codedirectory_cdhash(best_cd, cdhash);
}
// Compute the cdhash from a csblob.
@@ -338,7 +335,7 @@ csblob_cdhash(CS_GenericBlob *blob, size_t size, void *cdhash) {
if (!ok) {
return false;
}
- return cs_codedirectory_cdhash((CS_CodeDirectory *)blob, length, cdhash);
+ return cs_codedirectory_cdhash((CS_CodeDirectory *)blob, cdhash);
}
ERROR("Unrecognized CSBlob magic 0x%08x\n", magic);
return false;
@@ -349,7 +346,7 @@ static bool
compute_cdhash_macho(const struct mach_header_64 *mh, const struct mach_header *mh32, size_t size, struct hashes *cdhash) {
// Find the code signature command.
const struct linkedit_data_command *cs_cmd =
- macho_find_load_command(mh, mh32, size, LC_CODE_SIGNATURE, NULL);
+ macho_find_load_command(mh, mh32, LC_CODE_SIGNATURE, NULL);
if (cs_cmd == NULL) {
ERROR("No code signature\n");
return false;