summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-09-04 12:53:24 -0700
committerLinus Groh <mail@linusgroh.de>2021-09-05 09:48:43 +0100
commit3d12d0f408c8f4f8ec6fbcf8303659aeeec5e33f (patch)
tree99db35dcb79b4d87bffcd0870f92742c44baca8a /Kernel
parent9d1b27263f056ae40a573dcae73d2f8cf3fefe00 (diff)
downloadserenity-3d12d0f408c8f4f8ec6fbcf8303659aeeec5e33f.zip
Kernel: Declare syscall handlers with "using" instead of "typedef"
Also use bit_cast to avoid -Wcast-function-type warning.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Syscall.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 1579f862b7..3d840cd789 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -88,15 +88,15 @@ UNMAP_AFTER_INIT void initialize()
register_user_callable_interrupt_handler(syscall_vector, syscall_asm_entry);
}
-#pragma GCC diagnostic ignored "-Wcast-function-type"
-typedef KResultOr<FlatPtr> (Process::*Handler)(FlatPtr, FlatPtr, FlatPtr, FlatPtr);
-typedef KResultOr<FlatPtr> (Process::*HandlerWithRegisterState)(RegisterState&);
+using Handler = auto (Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> KResultOr<FlatPtr>;
+using HandlerWithRegisterState = auto (Process::*)(RegisterState&) -> KResultOr<FlatPtr>;
+
struct HandlerMetadata {
Handler handler;
NeedsBigProcessLock needs_lock;
};
-#define __ENUMERATE_SYSCALL(sys_call, needs_lock) { reinterpret_cast<Handler>(&Process::sys$##sys_call), needs_lock },
+#define __ENUMERATE_SYSCALL(sys_call, needs_lock) { bit_cast<Handler>(&Process::sys$##sys_call), needs_lock },
static const HandlerMetadata s_syscall_table[] = {
ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL)
};
@@ -153,7 +153,7 @@ KResultOr<FlatPtr> handle(RegisterState& regs, FlatPtr function, FlatPtr arg1, F
KResultOr<FlatPtr> result { FlatPtr(nullptr) };
if (function == SC_fork || function == SC_sigreturn) {
// These syscalls want the RegisterState& rather than individual parameters.
- auto handler = (HandlerWithRegisterState)syscall_metadata.handler;
+ auto handler = bit_cast<HandlerWithRegisterState>(syscall_metadata.handler);
result = (process.*(handler))(regs);
} else {
result = (process.*(syscall_metadata.handler))(arg1, arg2, arg3, arg4);