public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
To: u-boot@lists.denx.de
Subject: [PATCH] tools: fdtgrep: Use unsigned chars for arrays
Date: Wed, 10 Feb 2021 19:43:09 -0500	[thread overview]
Message-ID: <20210210194309.07d1dec7@DUFFMAN> (raw)

Otherwise, values over 127 end up prefixed with ffffff.

Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Cc: Simon Glass <sjg@chromium.org>
---

Minimal reproduction:

```
// repro.dts
/dts-v1/;

/ {
    ra = [ 7f ];
    rb = [ 80 ];
};
```

Steps used to compile:

 $ dtc repro.dts > repro.dtb

Without the fix:

 $ fdtgrep --include-node / repro.dtb
/ {
    ra = [7f];
    rb = [ffffff80];
};

With the fix:

 $ fdtgrep --include-node / repro.dtb
/ {
    ra = [7f];
    rb = [80];
};

---

 tools/fdtgrep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/fdtgrep.c b/tools/fdtgrep.c
index e4112b8f69..db512465db 100644
--- a/tools/fdtgrep.c
+++ b/tools/fdtgrep.c
@@ -213,7 +213,7 @@ static void utilfdt_print_data(const char *data, int len)
 	} else {
 		printf(" = [");
 		for (i = 0; i < len; i++)
-			printf("%02x%s", *p++, i < len - 1 ? " " : "");
+			printf("%02x%s", (unsigned char)*p++, i < len - 1 ? " " : "");
 		printf("]");
 	}
 }
-- 
2.29.2

             reply	other threads:[~2021-02-11  0:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11  0:43 Samuel Dionne-Riel [this message]
2021-02-13  4:17 ` [PATCH] tools: fdtgrep: Use unsigned chars for arrays Simon Glass
2021-03-16  5:58   ` Simon Glass

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=20210210194309.07d1dec7@DUFFMAN \
    --to=samuel@dionne-riel.com \
    --cc=u-boot@lists.denx.de \
    /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