From: Charles Perry <charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Charles Perry
<charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
Subject: [PATCH 2/2] dtc: ensure that command line options arrays length match
Date: Sun, 3 Sep 2023 19:00:58 -0700 [thread overview]
Message-ID: <20230904020058.1935334-2-charles.perry@savoirfairelinux.com> (raw)
In-Reply-To: <20230904020058.1935334-1-charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
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).
Signed-off-by: Charles Perry <charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
---
dtc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dtc.c b/dtc.c
index 775d527..2768fc6 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");
static const char *guess_type_by_name(const char *fname, const char *fallback)
{
--
2.34.1
next prev parent reply other threads:[~2023-09-04 2:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 2:00 [PATCH 1/2] dtc: fix missing string in usage_opts_help Charles Perry
[not found] ` <20230904020058.1935334-1-charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2023-09-04 2:00 ` Charles Perry [this message]
2023-09-04 2:51 ` David Gibson
2023-09-04 14:20 ` Charles Perry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230904020058.1935334-2-charles.perry@savoirfairelinux.com \
--to=charles.perry-4ysuxcep3am1wj+d4i0nrvatqe2ktcn/@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).