From c3a41e5d4cc53ec50791bdd1bafec286f6d11656 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 27 Jan 2023 13:41:17 +0800 Subject: [PATCH] btrfs-progs: move a union with variable sized type to the end [WARNING] Clang 15.0.7 gives the following warning: image/main.c:95:2: warning: field '' with variable sized type 'union metadump_struct::(anonymous at image/main.c:95:2)' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] union { ^ [CAUSE] The union contains meta_cluster, which variable sized: struct meta_cluster { struct meta_cluster_header header; struct meta_cluster_item items[]; } __attribute__ ((__packed__)); Thus clang gives above warning since it's a GNU extension. [FIX] Just move the union to the end of the structure. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- image/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/image/main.c b/image/main.c index dd75b47c..6f1670cb 100644 --- a/image/main.c +++ b/image/main.c @@ -93,11 +93,6 @@ struct metadump_struct { struct btrfs_root *root; FILE *out; - union { - struct meta_cluster cluster; - char meta_cluster_bytes[IMAGE_BLOCK_SIZE]; - }; - pthread_t threads[MAX_WORKER_THREADS]; size_t num_threads; pthread_mutex_t mutex; @@ -120,6 +115,11 @@ struct metadump_struct { enum sanitize_mode sanitize_names; int error; + + union { + struct meta_cluster cluster; + char meta_cluster_bytes[IMAGE_BLOCK_SIZE]; + }; }; struct mdrestore_struct {