From 2ece61fa1f1d3b198a6f8ebbef9c927fac94950a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 1 Dec 2019 16:47:28 +0100 Subject: [PATCH] LibCore: Improve logging of errors in safe_syscall() somewhat --- Libraries/LibCore/CSyscallUtils.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Libraries/LibCore/CSyscallUtils.h b/Libraries/LibCore/CSyscallUtils.h index 9a16901d11..cb65f3f702 100644 --- a/Libraries/LibCore/CSyscallUtils.h +++ b/Libraries/LibCore/CSyscallUtils.h @@ -1,18 +1,21 @@ #pragma once -#include -#include -#include +#include #include +#include +#include +#include namespace CSyscallUtils { -template -inline int safe_syscall(Syscall syscall, Args&& ... args) { +template +inline int safe_syscall(Syscall syscall, Args&&... args) +{ for (;;) { int sysret = syscall(forward(args)...); if (sysret == -1) { - dbgprintf("CSafeSyscall: %d (%d: %s)\n", sysret, errno, strerror(errno)); + int saved_errno = errno; + dbg() << "CSafeSyscall: " << sysret << " (" << saved_errno << ": " << strerror(saved_errno) << ")"; if (errno == EINTR) continue; ASSERT_NOT_REACHED(); @@ -22,4 +25,3 @@ inline int safe_syscall(Syscall syscall, Args&& ... args) { } } -