* [PATCH] tools: fw_env: Fix warning when reading too little
@ 2020-05-28 15:54 Harald Seiler
2020-06-03 16:26 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Harald Seiler @ 2020-05-28 15:54 UTC (permalink / raw)
To: u-boot
When using CONFIG_ENV_IS_IN_FAT and the config-file specifies a size
larger than what U-Boot wrote into the env-file, a confusing error
message is shown:
$ fw_printenv
Read error on /boot/uboot.env: Success
Fix this by showing a different error message when read returns too
little data.
Signed-off-by: Harald Seiler <hws@denx.de>
---
tools/env/fw_env.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 8734663cd4c7..c6378ecf34f6 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -946,11 +946,17 @@ static int flash_read_buf(int dev, int fd, void *buf, size_t count,
lseek(fd, blockstart + block_seek, SEEK_SET);
rc = read(fd, buf + processed, readlen);
- if (rc != readlen) {
+ if (rc == -1) {
fprintf(stderr, "Read error on %s: %s\n",
DEVNAME(dev), strerror(errno));
return -1;
}
+ if (rc != readlen) {
+ fprintf(stderr, "Read error on %s: "
+ "Attempted to read %d bytes but got %d\n",
+ DEVNAME(dev), readlen, rc);
+ return -1;
+ }
#ifdef DEBUG
fprintf(stderr, "Read 0x%x bytes at 0x%llx on %s\n",
rc, (unsigned long long)blockstart + block_seek,
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] tools: fw_env: Fix warning when reading too little
2020-05-28 15:54 [PATCH] tools: fw_env: Fix warning when reading too little Harald Seiler
@ 2020-06-03 16:26 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-06-03 16:26 UTC (permalink / raw)
To: u-boot
On Thu, May 28, 2020 at 05:54:45PM +0200, Harald Seiler wrote:
> When using CONFIG_ENV_IS_IN_FAT and the config-file specifies a size
> larger than what U-Boot wrote into the env-file, a confusing error
> message is shown:
>
> $ fw_printenv
> Read error on /boot/uboot.env: Success
>
> Fix this by showing a different error message when read returns too
> little data.
>
> Signed-off-by: Harald Seiler <hws@denx.de>
Applied to u-boot/master, thanks!
--
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/20200603/30965a4c/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-03 16:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 15:54 [PATCH] tools: fw_env: Fix warning when reading too little Harald Seiler
2020-06-03 16:26 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.