Skip to contentSkip to conversation

tools: env: Fix printf() warning in fw_env

PATCH New Simon Glass 2 participants 4 messages Aug 1, 2020 – Aug 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tools: env: Fix printf() warning in fw_env

The printf() string produces a warning about %d not matching size_t. Fix it and put the format string on one line to avoid a checkpatch warning.

---

 tools/env/fw_env.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/env/fw_env.c +2 -2
index 3ab1ae69c7a..ccbeb5552bc 100644
@@ -952,8 +952,8 @@ static int flash_read_buf(int dev, int fd, void *buf, size_t count,
 			return -1;
 		}
 		if (rc != readlen) {
-			fprintf(stderr, "Read error on %s: "
-				"Attempted to read %d bytes but got %d\n",
+			fprintf(stderr,
+				"Read error on %s: Attempted to read %zd bytes but got %d\n",
 				DEVNAME(dev), readlen, rc);
 			return -1;
 		}
Signature · 1 line
2.28.0.163.g6104cc2f0b6-goog
#1 lore raw

PATCH 2/2 tools: env: Avoid an uninited warning with was_locked

Set this variable to 0 to avoid a warning about an unused variable. This happens on gcc 7.5.0 for me.

---

 tools/env/fw_env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/env/fw_env.c +1 -1
index ccbeb5552bc..66cb9d2a25e 100644
@@ -995,7 +995,7 @@ static int flash_write_buf(int dev, int fd, void *buf, size_t count)
 				   of the data */
 	loff_t blockstart;	/* running start of the current block -
 				   MEMGETBADBLOCK needs 64 bits */
-	int was_locked;		/* flash lock flag */
+	int was_locked = 0;	/* flash lock flag */
 	int rc;
 
 	/*
Signature · 1 line
2.28.0.163.g6104cc2f0b6-goog
#2 lore raw

PATCH 2/2 tools: env: Avoid an uninited warning with was_locked

Quoted 4 lines · Simon Glass

Set this variable to 0 to avoid a warning about an unused variable. This happens on gcc 7.5.0 for me.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200805/147e362d/attachment.sig>
#3 lore raw

PATCH 1/2 tools: env: Fix printf() warning in fw_env

In reply to Simon Glass
Quoted 4 lines · Simon Glass

The printf() string produces a warning about %d not matching size_t. Fix it and put the format string on one line to avoid a checkpatch warning.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200805/84424caa/attachment.sig>