From ff85c8c0d9ea4513009d3867fa119b60e9ff86d5 Mon Sep 17 00:00:00 2001 From: zhangshoukui Date: Mon, 5 Aug 2024 19:29:52 +0800 Subject: [PATCH] fstest: If the file is deleted it will not be opened Signed-off-by: zhangshoukui --- testing/fstest/fstest_main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/testing/fstest/fstest_main.c b/testing/fstest/fstest_main.c index 9c57caedb..875419b0b 100644 --- a/testing/fstest/fstest_main.c +++ b/testing/fstest/fstest_main.c @@ -597,18 +597,19 @@ static inline int fstest_rdfile(FAR struct fstest_ctx_s *ctx, uint32_t crc; int fd; + if (file->deleted) + { + return ERROR; + } + /* Open the file for reading */ fd = open(file->name, O_RDONLY); if (fd < 0) { - if (!file->deleted) - { - printf("ERROR: Failed to open file for reading: %d\n", errno); - printf(" File name: %s\n", file->name); - printf(" File size: %zd\n", file->len); - } - + printf("ERROR: Failed to open file for reading: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %zd\n", file->len); return ERROR; }