From 0a4770b44a36d64273ba2e5aa9482bdbf011b0b8 Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Thu, 11 Jul 2024 16:44:17 +0800 Subject: [PATCH] lib_remove:Repair the logical judgment Summary: When the deleted path is a file, the return value of get_errno is -EISDIR, so in Condition Two (get_errno() ! = EPERM && /* .... . try to remove it. */ rmdir(path) ! = 0) The judgment holds directly, so it can't actually execute to rmdir Signed-off-by: chenrun1 --- libs/libc/stdio/lib_remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libc/stdio/lib_remove.c b/libs/libc/stdio/lib_remove.c index 650ac82da9..89a965092c 100644 --- a/libs/libc/stdio/lib_remove.c +++ b/libs/libc/stdio/lib_remove.c @@ -56,7 +56,7 @@ int remove(FAR const char *path) */ if (unlink(path) != 0 && /* If it is indeed a directory... */ - (get_errno() != EPERM || /* ...try to remove it. */ + (get_errno() != EISDIR || /* ...try to remove it. */ rmdir(path) != 0)) { /* Cannot remove the object for whatever reason. */