devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] dtc: fix missing string in usage_opts_help
@ 2023-09-04 14:31 Charles Perry
       [not found] ` <20230904143104.1941715-1-charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Charles Perry @ 2023-09-04 14:31 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Charles Perry

This fixes the output of the `dtc --help` command as the last few
entries were offset by one.

Signed-off-by: Charles Perry <charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
---
Put the string at the right place in usage_opts_help

 dtc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/dtc.c b/dtc.c
index d2e4e2b..0655c2e 100644
--- a/dtc.c
+++ b/dtc.c
@@ -105,6 +105,7 @@ static const char * const usage_opts_help[] = {
 	"\n\tEnable/disable warnings (prefix with \"no-\")",
 	"\n\tEnable/disable errors (prefix with \"no-\")",
 	"\n\tEnable generation of symbols",
+	"\n\tPossibly generates a __local_fixups__ and a __fixups__ node at the root node",
 	"\n\tEnable auto-alias of labels",
 	"\n\tAnnotate output .dts with input source file and line (-T -T for more details)",
 	"\n\tPrint this help and exit",
-- 
2.34.1


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

* [PATCH v2 2/2] dtc: ensure that command line options arrays length match
       [not found] ` <20230904143104.1941715-1-charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
@ 2023-09-04 14:31   ` Charles Perry
  2024-01-25  3:45     ` David Gibson
  2023-09-05  2:00   ` [PATCH v2 1/2] dtc: fix missing string in usage_opts_help David Gibson
  1 sibling, 1 reply; 4+ messages in thread
From: Charles Perry @ 2023-09-04 14:31 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Charles Perry

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 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


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

* Re: [PATCH v2 1/2] dtc: fix missing string in usage_opts_help
       [not found] ` <20230904143104.1941715-1-charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2023-09-04 14:31   ` [PATCH v2 2/2] dtc: ensure that command line options arrays length match Charles Perry
@ 2023-09-05  2:00   ` David Gibson
  1 sibling, 0 replies; 4+ messages in thread
From: David Gibson @ 2023-09-05  2:00 UTC (permalink / raw)
  To: Charles Perry; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]

On Mon, Sep 04, 2023 at 07:31:03AM -0700, Charles Perry wrote:
> This fixes the output of the `dtc --help` command as the last few
> entries were offset by one.
> 
> Signed-off-by: Charles Perry <charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>

Merged, thanks.

> ---
> Put the string at the right place in usage_opts_help
> 
>  dtc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/dtc.c b/dtc.c
> index d2e4e2b..0655c2e 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -105,6 +105,7 @@ static const char * const usage_opts_help[] = {
>  	"\n\tEnable/disable warnings (prefix with \"no-\")",
>  	"\n\tEnable/disable errors (prefix with \"no-\")",
>  	"\n\tEnable generation of symbols",
> +	"\n\tPossibly generates a __local_fixups__ and a __fixups__ node at the root node",
>  	"\n\tEnable auto-alias of labels",
>  	"\n\tAnnotate output .dts with input source file and line (-T -T for more details)",
>  	"\n\tPrint this help and exit",

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2 2/2] dtc: ensure that command line options arrays length match
  2023-09-04 14:31   ` [PATCH v2 2/2] dtc: ensure that command line options arrays length match Charles Perry
@ 2024-01-25  3:45     ` David Gibson
  0 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2024-01-25  3:45 UTC (permalink / raw)
  To: Charles Perry; +Cc: devicetree-compiler

[-- Attachment #1: Type: text/plain, Size: 1466 bytes --]

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 <charles.perry@savoirfairelinux.com>
> ---
>  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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2024-01-25  3:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04 14:31 [PATCH v2 1/2] dtc: fix missing string in usage_opts_help Charles Perry
     [not found] ` <20230904143104.1941715-1-charles.perry-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2023-09-04 14:31   ` [PATCH v2 2/2] dtc: ensure that command line options arrays length match Charles Perry
2024-01-25  3:45     ` David Gibson
2023-09-05  2:00   ` [PATCH v2 1/2] dtc: fix missing string in usage_opts_help David Gibson

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 NNTP newsgroup(s).