All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/3] fsck.gfs2: Fix 'initializer element is not constant' build error
@ 2015-01-27 15:52 Andrew Price
  2015-01-27 15:52 ` [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname Andrew Price
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrew Price @ 2015-01-27 15:52 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This error occurs when gfs2-utils is compiled with -std options more
recent than gnu89:

    CC       fsck_gfs2-main.o
  main.c:39:38: error: initializer element is not constant
   struct osi_root dup_blocks = (struct osi_root) { NULL, };
                                        ^
  main.c:40:35: error: initializer element is not constant
   struct osi_root dirtree = (struct osi_root) { NULL, };
                                     ^
  main.c:41:37: error: initializer element is not constant
   struct osi_root inodetree = (struct osi_root) { NULL, };
                                     ^
As far as I can tell, with C89/gnu89 the use of a cast in this context
is undefined behaviour and the later standards are more strict about it,
hence the error. As the standards specify that members of objects with
static storage duration are zeroed/NULLed anyway, the initializers can
be removed to achieve the intended result.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/fsck/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index a4af25d..658cd17 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -36,9 +36,9 @@ const char *pass = "";
 uint64_t last_data_block;
 uint64_t first_data_block;
 int preen = 0, force_check = 0;
-struct osi_root dup_blocks = (struct osi_root) { NULL, };
-struct osi_root dirtree = (struct osi_root) { NULL, };
-struct osi_root inodetree = (struct osi_root) { NULL, };
+struct osi_root dup_blocks;
+struct osi_root dirtree;
+struct osi_root inodetree;
 int dups_found = 0, dups_found_first = 0;
 struct gfs_sb *sbd1 = NULL;
 int sb_fixed = 0;
-- 
1.9.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-28 15:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 15:52 [Cluster-devel] [PATCH 1/3] fsck.gfs2: Fix 'initializer element is not constant' build error Andrew Price
2015-01-27 15:52 ` [Cluster-devel] [PATCH 2/3] fsck.gfs2: Simplify bad_journalname Andrew Price
2015-01-28 13:13   ` Bob Peterson
2015-01-28 15:14     ` Andrew Price
2015-01-27 15:52 ` [Cluster-devel] [PATCH 3/3] gfs2-utils build: Add a configure script summary Andrew Price
2015-01-28 13:13   ` Bob Peterson
2015-01-28 13:09 ` [Cluster-devel] [PATCH 1/3] fsck.gfs2: Fix 'initializer element is not constant' build error Bob Peterson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.