]> wimlib.net Git - wimlib/commitdiff
Avoid gcc warnings with -Waddress-of-packed-member
authorEric Biggers <ebiggers3@gmail.com>
Fri, 26 Jul 2019 05:11:33 +0000 (22:11 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 26 Jul 2019 05:11:33 +0000 (22:11 -0700)
- Remove unnecessary packed attributes.
- Access a packed structure directly rather than via a separate pointer.

include/wimlib/blob_table.h
include/wimlib/inode.h
src/registry.c

index ae4f9f4d27b826c0763f9a4d43bf8e878df57466..610db2419e2f9b96c8c0b079f8830d937848109f 100644 (file)
@@ -102,7 +102,7 @@ struct blob_descriptor {
                        struct wim_inode *back_inode;
                        u32 back_stream_id;
                };
                        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
 
        /* Number of times this blob is referenced by file streams in WIM
         * images.  See blob_decrement_refcnt() for information about the
index 610220988b31c7bf9b87df060a896b572bfe307d..4497775077415e337687136bf23f1068c46a0b27 100644 (file)
@@ -71,7 +71,7 @@ struct wim_inode_stream {
        union {
                u8 _stream_hash[SHA1_HASH_SIZE];
                struct blob_descriptor *_stream_blob;
        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.  */
 
        /* 'stream_resolved' determines whether 'stream_hash' or 'stream_blob'
         * is valid as described above.  */
index 8dc702fdbf0a6af815a4dadb6847ce77c508fbee..0f753e8c7de0b6bd58bc225f8c7eb5f7a420e88d 100644 (file)
@@ -243,7 +243,7 @@ iterate_subkeys_recursive(const struct regf *regf, le32 subkey_list_offset,
        unsigned num_offsets;
        size_t extra_size;
        unsigned increment;
        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)
        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;
 
                             sizeof(struct subkey_list) + extra_size))
                return HIVE_CORRUPT;
 
-       p = list->elements;
-
        switch (list->base.magic) {
        case LF_MAGIC:
        case LH_MAGIC:
        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;
 
                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 (!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;
                                                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:
                }
                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 = 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;
                }
                        if (status != HIVE_OK)
                                break;
                }