fix messed-up errno if remove fails for a non-EISDIR reason
[musl] / src / stdio / remove.c
index fc12f7c..e147ba2 100644 (file)
@@ -4,6 +4,6 @@
 
 int remove(const char *path)
 {
-       return (syscall(SYS_unlink, path) && errno == EISDIR)
-               ? syscall(SYS_rmdir, path) : 0;
+       int r = syscall(SYS_unlink, path);
+       return (r && errno == EISDIR) ? syscall(SYS_rmdir, path) : r;
 }