From 38bd45bb7e08f2072e256afd5bcc21ceb0d97b8e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 25 Jul 2019 22:11:33 -0700 Subject: [PATCH] Avoid gcc warnings with -Waddress-of-packed-member - Remove unnecessary packed attributes. - Access a packed structure directly rather than via a separate pointer. --- include/wimlib/blob_table.h | 2 +- include/wimlib/inode.h | 2 +- src/registry.c | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/wimlib/blob_table.h b/include/wimlib/blob_table.h index ae4f9f4d..610db241 100644 --- a/include/wimlib/blob_table.h +++ b/include/wimlib/blob_table.h @@ -102,7 +102,7 @@ struct blob_descriptor { struct wim_inode *back_inode; u32 back_stream_id; }; - } _packed_attribute; /* union is SHA1_HASH_SIZE bytes */ + }; /* Number of times this blob is referenced by file streams in WIM * images. See blob_decrement_refcnt() for information about the diff --git a/include/wimlib/inode.h b/include/wimlib/inode.h index 61022098..44977750 100644 --- a/include/wimlib/inode.h +++ b/include/wimlib/inode.h @@ -71,7 +71,7 @@ struct wim_inode_stream { union { u8 _stream_hash[SHA1_HASH_SIZE]; struct blob_descriptor *_stream_blob; - } _packed_attribute; /* union is SHA1_HASH_SIZE bytes */ + }; /* 'stream_resolved' determines whether 'stream_hash' or 'stream_blob' * is valid as described above. */ diff --git a/src/registry.c b/src/registry.c index 8dc702fd..0f753e8c 100644 --- a/src/registry.c +++ b/src/registry.c @@ -243,7 +243,7 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, unsigned num_offsets; size_t extra_size; unsigned increment; - const le32 *p; + size_t i = 0; enum hive_status status; if (stats->levels_remaining == 0 || stats->subkey_lists_remaining == 0) @@ -270,8 +270,6 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, sizeof(struct subkey_list) + extra_size)) return HIVE_CORRUPT; - p = list->elements; - switch (list->base.magic) { case LF_MAGIC: case LH_MAGIC: @@ -283,18 +281,20 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, while (num_offsets--) { const struct nk *sub_nk; - sub_nk = get_cell_pointer(regf, *p, sizeof(struct nk)); + sub_nk = get_cell_pointer(regf, list->elements[i], + sizeof(struct nk)); if (!sub_nk || sub_nk->base.magic != NK_MAGIC) return HIVE_CORRUPT; - if (!revalidate_cell(regf, *p, sizeof(struct nk) + + if (!revalidate_cell(regf, list->elements[i], + sizeof(struct nk) + le16_to_cpu(sub_nk->name_size))) return HIVE_CORRUPT; status = (*cb)(sub_nk, cb_ctx); if (status != HIVE_OK) return status; - p += increment; + i += increment; } return HIVE_OK; case RI_MAGIC: @@ -302,8 +302,9 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset, status = HIVE_OK; stats->levels_remaining--; while (num_offsets--) { - status = iterate_subkeys_recursive(regf, *p++, - cb, cb_ctx, stats); + status = iterate_subkeys_recursive(regf, + list->elements[i++], + cb, cb_ctx, stats); if (status != HIVE_OK) break; } -- 2.43.0