On Mon, Sep 04, 2023 at 07:31:04AM -0700, Charles Perry wrote: > usage_long_opts and usage_opts_help should always have the same length. > Since these are fixed length arrays, this can be checked at compile time > with _Static_assert (requires C11). Sorry I've taken so long to reply. I like the idea here, and I'm ok with C11 being required for dtc (although I'd prefer to keep libfdt to c99). But, because this does introduce a new dependency I'd like to see it come after a patch making that a bit more formal - adding compiler flags to enforce it, for example. > Signed-off-by: Charles Perry > --- > dtc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/dtc.c b/dtc.c > index 0655c2e..1f38b97 100644 > --- a/dtc.c > +++ b/dtc.c > @@ -112,6 +112,8 @@ static const char * const usage_opts_help[] = { > "\n\tPrint version and exit", > NULL, > }; > +_Static_assert(ARRAY_SIZE(usage_long_opts) == ARRAY_SIZE(usage_opts_help), > + "usage_long_opts and usage_opts_help length differ"); Also, IIUC, C11 also requires the less ugly 'static_assert' macro which amounts to the same thing. > > static const char *guess_type_by_name(const char *fname, const char *fallback) > { -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson