summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nand-utils/nanddump.c3
-rw-r--r--nand-utils/nandwrite.c3
-rw-r--r--nor-utils/rfddump.c2
-rw-r--r--tests/fs-tests/stress/atoms/fwrite00.c4
4 files changed, 8 insertions, 4 deletions
diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c
index 841ed67..62699e0 100644
--- a/nand-utils/nanddump.c
+++ b/nand-utils/nanddump.c
@@ -549,7 +549,8 @@ int main(int argc, char * const argv[])
closeall:
close(fd);
- close(ofd);
+ if (ofd > 0 && ofd != STDOUT_FILENO)
+ close(ofd);
free(oobbuf);
free(readbuf);
exit(EXIT_FAILURE);
diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c
index 8f21593..e8a210c 100644
--- a/nand-utils/nandwrite.c
+++ b/nand-utils/nandwrite.c
@@ -605,7 +605,8 @@ int main(int argc, char * const argv[])
failed = false;
closeall:
- close(ifd);
+ if (ifd > 0 && ifd != STDIN_FILENO)
+ close(ifd);
libmtd_close(mtd_desc);
free(filebuf);
close(fd);
diff --git a/nor-utils/rfddump.c b/nor-utils/rfddump.c
index 4ad2f91..01ab4c2 100644
--- a/nor-utils/rfddump.c
+++ b/nor-utils/rfddump.c
@@ -324,7 +324,7 @@ int main(int argc, char *argv[])
return 0;
err:
- if (out_fd)
+ if (out_fd > 0)
close(out_fd);
close(fd);
diff --git a/tests/fs-tests/stress/atoms/fwrite00.c b/tests/fs-tests/stress/atoms/fwrite00.c
index 3406bba..877c63c 100644
--- a/tests/fs-tests/stress/atoms/fwrite00.c
+++ b/tests/fs-tests/stress/atoms/fwrite00.c
@@ -138,7 +138,9 @@ static void filestress00(void)
deleted = 1;
}
}
- CHECK(close(fd) != -1);
+ if (fd > 0) {
+ CHECK(close(fd) != -1);
+ }
/* Sleep */
if (tests_sleep_parameter > 0) {
unsigned us = tests_sleep_parameter * 1000;