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>
lime2-spi
Alexander Dahl 6 years ago committed by Tom Rini
parent 8dc4e1fbf4
commit 3559028cb2
  1. 2
      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;

Loading…
Cancel
Save