]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkzone: don't take address of struct blk_zone
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 31 May 2023 10:47:03 +0000 (12:47 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Thu, 1 Jun 2023 10:16:34 +0000 (12:16 +0200)
Older versions of GCC do not know the warning so they warn about the
unknown ignored warning.

As struct blk_zone is only 64 bytes anyway just copy it.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
sys-utils/blkzone.c

index ff6eff10d75a4a1d5a29b011833bfca2a3d0bb1d..81191e1bc596f10aab0dd0798b1f6bc7d3fa203e 100644 (file)
@@ -271,19 +271,12 @@ static int blkzone_report(struct blkzone_control *ctl)
                        break;
 
                for (i = 0; i < zi->nr_zones; i++) {
-/*
- * blk_zone_report hasn't been packed since https://github.com/torvalds/linux/commit/b3e7e7d2d668de0102264302a4d10dd9d4438a42
- * was merged. See https://github.com/util-linux/util-linux/issues/1083
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
-                       const struct blk_zone *entry = &zi->zones[i];
-#pragma GCC diagnostic pop
-                       unsigned int type = entry->type;
-                       uint64_t start = entry->start;
-                       uint64_t wp = entry->wp;
-                       uint8_t cond = entry->cond;
-                       uint64_t len = entry->len;
+                       const struct blk_zone entry = zi->zones[i];
+                       unsigned int type = entry.type;
+                       uint64_t start = entry.start;
+                       uint64_t wp = entry.wp;
+                       uint8_t cond = entry.cond;
+                       uint64_t len = entry.len;
                        uint64_t cap;
 
                        if (!len) {
@@ -292,9 +285,9 @@ static int blkzone_report(struct blkzone_control *ctl)
                        }
 
                        if (has_zone_capacity(zi))
-                               cap = zone_capacity(entry);
+                               cap = zone_capacity(&entry);
                        else
-                               cap = entry->len;
+                               cap = entry.len;
 
                        if (only_capacity_sum) {
                                capacity_sum += cap;
@@ -303,7 +296,7 @@ static int blkzone_report(struct blkzone_control *ctl)
                                        ", cap 0x%06"PRIx64", wptr 0x%06"PRIx64
                                        " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
                                        start, len, cap, (type == 0x1) ? 0 : wp - start,
-                                       entry->reset, entry->non_seq,
+                                       entry.reset, entry.non_seq,
                                        cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
                                        type, type_text[type]);
                        } else {
@@ -311,7 +304,7 @@ static int blkzone_report(struct blkzone_control *ctl)
                                        ", wptr 0x%06"PRIx64
                                        " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
                                        start, len, (type == 0x1) ? 0 : wp - start,
-                                       entry->reset, entry->non_seq,
+                                       entry.reset, entry.non_seq,
                                        cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
                                        type, type_text[type]);
                        }