[libc-commits] [libc] 64be9da - [libc] Simplify execve syscall error handling (#242601)

via libc-commits libc-commits at lists.llvm.org
Sat Nov 14 17:54:32 PST 2026


Author: Connector Switch
Date: 2026-11-15T09:54:27+08:00
New Revision: 64be9dafb5542cdea0b9cb68b3f30cb4181b5d72

URL: https://github.com/llvm/llvm-project/commit/64be9dafb5542cdea0b9cb68b3f30cb4181b5d72
DIFF: https://github.com/llvm/llvm-project/commit/64be9dafb5542cdea0b9cb68b3f30cb4181b5d72.diff

LOG: [libc] Simplify execve syscall error handling (#242601)

Use syscall_checked<int> in the execve wrapper instead of converting
syscall errors by hand.

Added: 
    

Modified: 
    libc/src/__support/OSUtil/linux/syscall_wrappers/execve.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/execve.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/execve.h
index 9c88b7603e808..9bc327f8b47cd 100644
--- a/libc/src/__support/OSUtil/linux/syscall_wrappers/execve.h
+++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/execve.h
@@ -15,7 +15,7 @@
 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_SYSCALL_WRAPPERS_EXECVE_H
 
 #include "hdr/fcntl_macros.h"
-#include "src/__support/OSUtil/linux/syscall.h" // syscall_impl
+#include "src/__support/OSUtil/linux/syscall.h" // syscall_checked
 #include "src/__support/common.h"
 #include "src/__support/error_or.h"
 #include "src/__support/macros/config.h"
@@ -27,15 +27,12 @@ namespace linux_syscalls {
 LIBC_INLINE ErrorOr<int> execve(const char *path, char *const argv[],
                                 char *const envp[]) {
 #if defined(SYS_execve)
-  int ret = syscall_impl<int>(SYS_execve, path, argv, envp);
+  return syscall_checked<int>(SYS_execve, path, argv, envp);
 #elif defined(SYS_execveat)
-  int ret = syscall_impl<int>(SYS_execveat, AT_FDCWD, path, argv, envp, 0);
+  return syscall_checked<int>(SYS_execveat, AT_FDCWD, path, argv, envp, 0);
 #else
 #error "execve and execveat syscalls not available."
 #endif
-  if (ret < 0)
-    return Error(-ret);
-  return ret;
 }
 
 } // namespace linux_syscalls


        


More information about the libc-commits mailing list