On Sun, Sep 8, 2024 at 9:57 PM Dmitry Chestnykh dm.chestnykh@gmail.com wrote:
clang rejects the code where function body is placed inside body of another function
Signed-off-by: Dmitry Chestnykh dm.chestnykh@gmail.com
libc/sysdeps/linux/common/rename.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libc/sysdeps/linux/common/rename.c b/libc/sysdeps/linux/common/rename.c index 613ae4e44..821467e3c 100644 --- a/libc/sysdeps/linux/common/rename.c +++ b/libc/sysdeps/linux/common/rename.c @@ -18,10 +18,12 @@ int rename(const char *oldpath, const char *newpath) } #elif defined __NR_renameat2 # include <fcntl.h>
+_syscall5(int, renameat2, int, olddfd, const char *, oldpath,
int, newdfd, const char *, newpath, int, flags)
int rename(const char *oldpath, const char *newpath) {
_syscall5(int, renameat2, int, olddfd, const char *, oldpath,
int, newdfd, const char *, newpath, int, flags) return renameat2(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
}
I wonder why this duplication is needed at all, in the #if block above rename() is implemented via renameat(), and renameat() already wraps both renameat and renameat2 syscalls. Could this #else block just be collapsed with the above #if?