summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHarald Seiler <hws@denx.de>2020-05-28 17:54:45 +0200
committerTom Rini <trini@konsulko.com>2020-06-02 13:06:14 -0400
commit50bb682c5cc52769e7cbd835a00dbcbc75a4f0e7 (patch)
tree944af99afe1442b42cf68a845900994231d3bdd6 /tools
parent95712afc17bb4141e7f902983fb27e5bbc5aa62f (diff)
downloadu-boot-50bb682c5cc52769e7cbd835a00dbcbc75a4f0e7.tar.gz
tools: fw_env: Fix warning when reading too little
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/env/fw_env.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 8734663cd4..c6378ecf34 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,