diff options
author | Alexander Dahl <ada@thorsis.com> | 2018-04-20 15:29:30 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-04-28 18:32:24 -0400 |
commit | 3559028cb2840cc283652f4b7e4e1b457e6ec6a5 (patch) | |
tree | 51b991b8fd3be1921711e191b2217ebd254af3df /tools/mkenvimage.c | |
parent | 8dc4e1fbf439d63082419640b6e797dfdfcc4720 (diff) | |
download | u-boot-3559028cb2840cc283652f4b7e4e1b457e6ec6a5.tar.gz u-boot-3559028cb2840cc283652f4b7e4e1b457e6ec6a5.tar.bz2 u-boot-3559028cb2840cc283652f4b7e4e1b457e6ec6a5.zip |
tools: mkenvimage: Fix read() stdin error handling
On success read() returns the number of bytes read or zero for EOF. On
error -1 is returned and errno is set, so the right way to test if read
had failed is to test the return value instead of errno.
Signed-off-by: Alexander Dahl <ada@thorsis.com>
Diffstat (limited to 'tools/mkenvimage.c')
-rw-r--r-- | tools/mkenvimage.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 8eee72e257..716cb73a5c 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -168,7 +168,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } readbytes = read(txt_fd, filebuf + filesize, readlen); - if (errno) { + if (readbytes < 0) { fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); return EXIT_FAILURE; |