[PATCH v3 2/8] syscalls.cc: Deduplicate remove
Ben Wijen
ben@wijen.net
Fri Jan 22 15:47:12 GMT 2021
The remove code is already in the _remove_r function.
So, just call the _remove_r function.
---
winsup/cygwin/syscalls.cc | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 8651cfade..e6ff0fd7a 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1161,24 +1161,15 @@ _remove_r (struct _reent *, const char *ourname)
return -1;
}
- return win32_name.isdir () ? rmdir (ourname) : unlink (ourname);
+ int res = win32_name.isdir () ? rmdir (ourname) : unlink (ourname);
+ syscall_printf ("%R = remove(%s)", res, ourname);
+ return res;
}
extern "C" int
remove (const char *ourname)
{
- path_conv win32_name (ourname, PC_SYM_NOFOLLOW);
-
- if (win32_name.error)
- {
- set_errno (win32_name.error);
- syscall_printf ("-1 = remove (%s)", ourname);
- return -1;
- }
-
- int res = win32_name.isdir () ? rmdir (ourname) : unlink (ourname);
- syscall_printf ("%R = remove(%s)", res, ourname);
- return res;
+ return _remove_r (_REENT, ourname);
}
extern "C" pid_t
--
2.30.0
More information about the Cygwin-patches
mailing list