aboutsummaryrefslogtreecommitdiff
path: root/tools/mkenvimage.c
diff options
context:
space:
mode:
authorAlexander Dahl2018-04-20 15:29:30 +0200
committerTom Rini2018-04-28 18:32:24 -0400
commit3559028cb2840cc283652f4b7e4e1b457e6ec6a5 (patch)
tree51b991b8fd3be1921711e191b2217ebd254af3df /tools/mkenvimage.c
parent8dc4e1fbf439d63082419640b6e797dfdfcc4720 (diff)
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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index 8eee72e2572..716cb73a5c6 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;