[ccan] [PATCH 1/2] opt: Fix -Wmissing-field-initializers warning

Joel Stanley joel at jms.id.au
Mon Feb 7 15:06:15 EST 2011


OPT_ENDTABLE does not initalise all the elements in stuct opt_table.
When compliling with -Wextra -Wmissing-field-initializers is enabled,
which produces the following warning:

        iviewiir.c:299:9: error: missing field 'cb' initializer
              [-Wmissing-field-initializers]
                OPT_ENDTABLE
                ^
        In file included from iviewiir.c:12:
        ./ccan/opt/opt.h:82:38: note: instantiated from:
        #define OPT_ENDTABLE { NULL, OPT_END }
                                             ^
By changing the definition of OPT_ENDTABLE to initalise all 7 elements
of struct opt_table, the warning is silenced.
---
 ccan/opt/opt.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ccan/opt/opt.h b/ccan/opt/opt.h
index 8796752..a1adc41 100644
--- a/ccan/opt/opt.h
+++ b/ccan/opt/opt.h
@@ -79,7 +79,7 @@ struct opt_table;
  *
  * This must be the final element in the opt_table array.
  */
-#define OPT_ENDTABLE { NULL, OPT_END }
+#define OPT_ENDTABLE { NULL, OPT_END, NULL, NULL, NULL, NULL, NULL }
 
 /**
  * opt_register_table - register a table of options
-- 
1.7.2.3



More information about the ccan mailing list