[PATCH v2 2/2] dtc: ensure that command line options arrays length match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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@xxxxxxxxxxxxxxxxxxxx>
---
 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");
 
 static const char *guess_type_by_name(const char *fname, const char *fallback)
 {
-- 
2.34.1




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux