diff mbox series

libfdt: Remove superfluous NUL character from overlay symbols

Message ID 20200522164136.26069-1-marcus@mc.pp.se
State Accepted
Commit 42a768c6892ba3bdedea75a430dff234fddffc8d
Headers show
Series libfdt: Remove superfluous NUL character from overlay symbols | expand

Commit Message

Marcus Comstedt May 22, 2020, 4:41 p.m. UTC
The symbol path already ends with a NUL character (something which is
actually checked by the code) and this NUL is included in
rel_path_len, so there is no need to add a second one.

This change fixes incorrect display in "fdt list /__symbols" after
applying an overlay with symbols.

Signed-off-by: Marcus Comstedt <marcus at mc.pp.se>
---
 scripts/dtc/libfdt/fdt_overlay.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Simon Glass May 22, 2020, 11:13 p.m. UTC | #1
Hi Marcus,

On Fri, 22 May 2020 at 10:42, Marcus Comstedt <marcus at mc.pp.se> wrote:
>
> The symbol path already ends with a NUL character (something which is
> actually checked by the code) and this NUL is included in
> rel_path_len, so there is no need to add a second one.
>
> This change fixes incorrect display in "fdt list /__symbols" after
> applying an overlay with symbols.
>
> Signed-off-by: Marcus Comstedt <marcus at mc.pp.se>
> ---
>  scripts/dtc/libfdt/fdt_overlay.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Could you please send this patch upstream?

>
> diff --git a/scripts/dtc/libfdt/fdt_overlay.c b/scripts/dtc/libfdt/fdt_overlay.c
> index c090e6991e..bd75e3dd78 100644
> --- a/scripts/dtc/libfdt/fdt_overlay.c
> +++ b/scripts/dtc/libfdt/fdt_overlay.c
> @@ -757,7 +757,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
>                            && (memcmp(s, "/__overlay__", len - 1) == 0)) {
>                         /* /<fragment-name>/__overlay__ */
>                         rel_path = "";
> -                       rel_path_len = 0;
> +                       rel_path_len = 1; /* Include NUL character */
>                 } else {
>                         /* Symbol refers to something that won't end
>                          * up in the target tree */
> @@ -794,7 +794,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
>                 }
>
>                 ret = fdt_setprop_placeholder(fdt, root_sym, name,
> -                               len + (len > 1) + rel_path_len + 1, &p);
> +                               len + (len > 1) + rel_path_len, &p);
>                 if (ret < 0)
>                         return ret;
>
> @@ -820,7 +820,6 @@ static int overlay_symbol_update(void *fdt, void *fdto)
>
>                 buf[len] = '/';
>                 memcpy(buf + len + 1, rel_path, rel_path_len);
> -               buf[len + 1 + rel_path_len] = '\0';
>         }
>
>         return 0;
> --
> 2.26.2
>

Regards,
Simon
Marcus Comstedt May 23, 2020, 11:57 a.m. UTC | #2
Hi Simon,


Simon Glass <sjg at chromium.org> writes:

> Could you please send this patch upstream?


Sure.  But where is that, exactly?


  // Marcus
Simon Glass May 23, 2020, 2:57 p.m. UTC | #3
+Devicetree Compiler

On Sat, 23 May 2020 at 05:57, Marcus Comstedt <marcus at mc.pp.se> wrote:
>
>
> Hi Simon,
>
>
> Simon Glass <sjg at chromium.org> writes:
>
> > Could you please send this patch upstream?
>
>
> Sure.  But where is that, exactly?
>
>
>   // Marcus
>
>

Hi Marcus,

You can send your patch to the mailing list on cc.

Also see README.fdt-control fo the the git repo and other details.

Regards,
Simon
Marcus Comstedt May 23, 2020, 3:13 p.m. UTC | #4
Hi Simon,

Simon Glass <sjg at chromium.org> writes:

> You can send your patch to the mailing list on cc.
>
> Also see README.fdt-control fo the the git repo and other details.


Thanks.  Sent.


  // Marcus
Simon Glass May 25, 2020, 2:15 a.m. UTC | #5
On Sat, 23 May 2020 at 09:13, Marcus Comstedt <marcus at mc.pp.se> wrote:
>
>
> Hi Simon,
>
> Simon Glass <sjg at chromium.org> writes:
>
> > You can send your patch to the mailing list on cc.
> >
> > Also see README.fdt-control fo the the git repo and other details.
>
>
> Thanks.  Sent.
>
>
>   // Marcus
>
>

Reviewed-by: Simon Glass <sjg at chromium.org>
diff mbox series

Patch

diff --git a/scripts/dtc/libfdt/fdt_overlay.c b/scripts/dtc/libfdt/fdt_overlay.c
index c090e6991e..bd75e3dd78 100644
--- a/scripts/dtc/libfdt/fdt_overlay.c
+++ b/scripts/dtc/libfdt/fdt_overlay.c
@@ -757,7 +757,7 @@  static int overlay_symbol_update(void *fdt, void *fdto)
 			   && (memcmp(s, "/__overlay__", len - 1) == 0)) {
 			/* /<fragment-name>/__overlay__ */
 			rel_path = "";
-			rel_path_len = 0;
+			rel_path_len = 1; /* Include NUL character */
 		} else {
 			/* Symbol refers to something that won't end
 			 * up in the target tree */
@@ -794,7 +794,7 @@  static int overlay_symbol_update(void *fdt, void *fdto)
 		}
 
 		ret = fdt_setprop_placeholder(fdt, root_sym, name,
-				len + (len > 1) + rel_path_len + 1, &p);
+				len + (len > 1) + rel_path_len, &p);
 		if (ret < 0)
 			return ret;
 
@@ -820,7 +820,6 @@  static int overlay_symbol_update(void *fdt, void *fdto)
 
 		buf[len] = '/';
 		memcpy(buf + len + 1, rel_path, rel_path_len);
-		buf[len + 1 + rel_path_len] = '\0';
 	}
 
 	return 0;