From 3743ee8e4d7ef033f69403d28ef638c8a67010bb Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 17 Sep 2022 13:37:02 +0900 Subject: [PATCH] kernel: enable -Wstrict-prototypes --- Makefile | 2 +- kernel/audio/snd.c | 2 +- kernel/sys/syscall.c | 161 ++++++++++++++++++++-------------------- kernel/video/lfbvideo.c | 2 +- 4 files changed, 84 insertions(+), 83 deletions(-) diff --git a/Makefile b/Makefile index e517c21c..7b9bd66c 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ STRIP= ${TARGET}-strip # CFLAGS for kernel objects and modules KERNEL_CFLAGS = -ffreestanding -O2 -std=gnu11 -g -static -KERNEL_CFLAGS += -Wall -Wextra -Wno-unused-function -Wno-unused-parameter +KERNEL_CFLAGS += -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wstrict-prototypes KERNEL_CFLAGS += -pedantic -Wwrite-strings ${ARCH_KERNEL_CFLAGS} # Defined constants for the kernel diff --git a/kernel/audio/snd.c b/kernel/audio/snd.c index 8bf8d064..ddb760fd 100644 --- a/kernel/audio/snd.c +++ b/kernel/audio/snd.c @@ -273,7 +273,7 @@ int snd_request_buf(snd_device_t * device, uint32_t size, uint8_t *buffer) { return size; } -static snd_device_t * snd_main_device() { +static snd_device_t * snd_main_device(void) { spin_lock(_devices_lock); foreach(node, &_devices) { spin_unlock(_devices_lock); diff --git a/kernel/sys/syscall.c b/kernel/sys/syscall.c index e3029dcb..e012a371 100644 --- a/kernel/sys/syscall.c +++ b/kernel/sys/syscall.c @@ -1159,90 +1159,91 @@ long sys_times(struct tms *buf) { extern long ptrace_handle(long,pid_t,void*,void*); -static long (*syscalls[])() = { - /* System Call Table */ - [SYS_EXT] = sys_exit, - [SYS_GETEUID] = sys_geteuid, - [SYS_OPEN] = sys_open, - [SYS_READ] = sys_read, - [SYS_WRITE] = sys_write, - [SYS_CLOSE] = sys_close, - [SYS_GETTIMEOFDAY] = sys_gettimeofday, - [SYS_GETPID] = sys_getpid, - [SYS_SBRK] = sys_sbrk, - [SYS_UNAME] = sys_uname, - [SYS_SEEK] = sys_seek, - [SYS_STAT] = sys_stat, - [SYS_GETUID] = sys_getuid, - [SYS_SETUID] = sys_setuid, - [SYS_READDIR] = sys_readdir, - [SYS_CHDIR] = sys_chdir, - [SYS_GETCWD] = sys_getcwd, - [SYS_SETHOSTNAME] = sys_sethostname, - [SYS_GETHOSTNAME] = sys_gethostname, - [SYS_MKDIR] = sys_mkdir, - [SYS_GETTID] = sys_gettid, - [SYS_SYSFUNC] = sys_sysfunc, - [SYS_IOCTL] = sys_ioctl, - [SYS_ACCESS] = sys_access, - [SYS_STATF] = sys_statf, - [SYS_CHMOD] = sys_chmod, - [SYS_UMASK] = sys_umask, - [SYS_UNLINK] = sys_unlink, - [SYS_MOUNT] = sys_mount, - [SYS_SYMLINK] = sys_symlink, - [SYS_READLINK] = sys_readlink, - [SYS_LSTAT] = sys_lstat, - [SYS_CHOWN] = sys_chown, - [SYS_SETSID] = sys_setsid, - [SYS_SETPGID] = sys_setpgid, - [SYS_GETPGID] = sys_getpgid, - [SYS_DUP2] = sys_dup2, - [SYS_EXECVE] = sys_execve, - [SYS_FORK] = sys_fork, - [SYS_WAITPID] = sys_waitpid, - [SYS_YIELD] = sys_yield, - [SYS_SLEEPABS] = sys_sleepabs, - [SYS_SLEEP] = sys_sleep, - [SYS_PIPE] = sys_pipe, - [SYS_FSWAIT] = sys_fswait, - [SYS_FSWAIT2] = sys_fswait_timeout, - [SYS_FSWAIT3] = sys_fswait_multi, - [SYS_CLONE] = sys_clone, - [SYS_OPENPTY] = sys_openpty, - [SYS_SHM_OBTAIN] = sys_shm_obtain, - [SYS_SHM_RELEASE] = sys_shm_release, - [SYS_SIGNAL] = sys_signal, - [SYS_KILL] = sys_kill, - [SYS_REBOOT] = sys_reboot, - [SYS_GETGID] = sys_getgid, - [SYS_GETEGID] = sys_getegid, - [SYS_SETGID] = sys_setgid, - [SYS_GETGROUPS] = sys_getgroups, - [SYS_SETGROUPS] = sys_setgroups, - [SYS_TIMES] = sys_times, - [SYS_PTRACE] = ptrace_handle, - [SYS_SETTIMEOFDAY] = sys_settimeofday, - [SYS_SIGACTION] = sys_sigaction, - [SYS_SIGPENDING] = sys_sigpending, - [SYS_SIGPROCMASK] = sys_sigprocmask, - [SYS_SIGSUSPEND] = sys_sigsuspend_cur, - [SYS_SIGWAIT] = sys_sigwait, +typedef long (*scall_func)(long,long,long,long,long); - [SYS_SOCKET] = net_socket, - [SYS_SETSOCKOPT] = net_setsockopt, - [SYS_BIND] = net_bind, - [SYS_ACCEPT] = net_accept, - [SYS_LISTEN] = net_listen, - [SYS_CONNECT] = net_connect, - [SYS_GETSOCKOPT] = net_getsockopt, - [SYS_RECV] = net_recv, - [SYS_SEND] = net_send, - [SYS_SHUTDOWN] = net_shutdown, +static scall_func syscalls[] = { + /* System Call Table */ + [SYS_EXT] = (scall_func)(uintptr_t)sys_exit, + [SYS_GETEUID] = (scall_func)(uintptr_t)sys_geteuid, + [SYS_OPEN] = (scall_func)(uintptr_t)sys_open, + [SYS_READ] = (scall_func)(uintptr_t)sys_read, + [SYS_WRITE] = (scall_func)(uintptr_t)sys_write, + [SYS_CLOSE] = (scall_func)(uintptr_t)sys_close, + [SYS_GETTIMEOFDAY] = (scall_func)(uintptr_t)sys_gettimeofday, + [SYS_GETPID] = (scall_func)(uintptr_t)sys_getpid, + [SYS_SBRK] = (scall_func)(uintptr_t)sys_sbrk, + [SYS_UNAME] = (scall_func)(uintptr_t)sys_uname, + [SYS_SEEK] = (scall_func)(uintptr_t)sys_seek, + [SYS_STAT] = (scall_func)(uintptr_t)sys_stat, + [SYS_GETUID] = (scall_func)(uintptr_t)sys_getuid, + [SYS_SETUID] = (scall_func)(uintptr_t)sys_setuid, + [SYS_READDIR] = (scall_func)(uintptr_t)sys_readdir, + [SYS_CHDIR] = (scall_func)(uintptr_t)sys_chdir, + [SYS_GETCWD] = (scall_func)(uintptr_t)sys_getcwd, + [SYS_SETHOSTNAME] = (scall_func)(uintptr_t)sys_sethostname, + [SYS_GETHOSTNAME] = (scall_func)(uintptr_t)sys_gethostname, + [SYS_MKDIR] = (scall_func)(uintptr_t)sys_mkdir, + [SYS_GETTID] = (scall_func)(uintptr_t)sys_gettid, + [SYS_SYSFUNC] = (scall_func)(uintptr_t)sys_sysfunc, + [SYS_IOCTL] = (scall_func)(uintptr_t)sys_ioctl, + [SYS_ACCESS] = (scall_func)(uintptr_t)sys_access, + [SYS_STATF] = (scall_func)(uintptr_t)sys_statf, + [SYS_CHMOD] = (scall_func)(uintptr_t)sys_chmod, + [SYS_UMASK] = (scall_func)(uintptr_t)sys_umask, + [SYS_UNLINK] = (scall_func)(uintptr_t)sys_unlink, + [SYS_MOUNT] = (scall_func)(uintptr_t)sys_mount, + [SYS_SYMLINK] = (scall_func)(uintptr_t)sys_symlink, + [SYS_READLINK] = (scall_func)(uintptr_t)sys_readlink, + [SYS_LSTAT] = (scall_func)(uintptr_t)sys_lstat, + [SYS_CHOWN] = (scall_func)(uintptr_t)sys_chown, + [SYS_SETSID] = (scall_func)(uintptr_t)sys_setsid, + [SYS_SETPGID] = (scall_func)(uintptr_t)sys_setpgid, + [SYS_GETPGID] = (scall_func)(uintptr_t)sys_getpgid, + [SYS_DUP2] = (scall_func)(uintptr_t)sys_dup2, + [SYS_EXECVE] = (scall_func)(uintptr_t)sys_execve, + [SYS_FORK] = (scall_func)(uintptr_t)sys_fork, + [SYS_WAITPID] = (scall_func)(uintptr_t)sys_waitpid, + [SYS_YIELD] = (scall_func)(uintptr_t)sys_yield, + [SYS_SLEEPABS] = (scall_func)(uintptr_t)sys_sleepabs, + [SYS_SLEEP] = (scall_func)(uintptr_t)sys_sleep, + [SYS_PIPE] = (scall_func)(uintptr_t)sys_pipe, + [SYS_FSWAIT] = (scall_func)(uintptr_t)sys_fswait, + [SYS_FSWAIT2] = (scall_func)(uintptr_t)sys_fswait_timeout, + [SYS_FSWAIT3] = (scall_func)(uintptr_t)sys_fswait_multi, + [SYS_CLONE] = (scall_func)(uintptr_t)sys_clone, + [SYS_OPENPTY] = (scall_func)(uintptr_t)sys_openpty, + [SYS_SHM_OBTAIN] = (scall_func)(uintptr_t)sys_shm_obtain, + [SYS_SHM_RELEASE] = (scall_func)(uintptr_t)sys_shm_release, + [SYS_SIGNAL] = (scall_func)(uintptr_t)sys_signal, + [SYS_KILL] = (scall_func)(uintptr_t)sys_kill, + [SYS_REBOOT] = (scall_func)(uintptr_t)sys_reboot, + [SYS_GETGID] = (scall_func)(uintptr_t)sys_getgid, + [SYS_GETEGID] = (scall_func)(uintptr_t)sys_getegid, + [SYS_SETGID] = (scall_func)(uintptr_t)sys_setgid, + [SYS_GETGROUPS] = (scall_func)(uintptr_t)sys_getgroups, + [SYS_SETGROUPS] = (scall_func)(uintptr_t)sys_setgroups, + [SYS_TIMES] = (scall_func)(uintptr_t)sys_times, + [SYS_PTRACE] = (scall_func)(uintptr_t)ptrace_handle, + [SYS_SETTIMEOFDAY] = (scall_func)(uintptr_t)sys_settimeofday, + [SYS_SIGACTION] = (scall_func)(uintptr_t)sys_sigaction, + [SYS_SIGPENDING] = (scall_func)(uintptr_t)sys_sigpending, + [SYS_SIGPROCMASK] = (scall_func)(uintptr_t)sys_sigprocmask, + [SYS_SIGSUSPEND] = (scall_func)(uintptr_t)sys_sigsuspend_cur, + [SYS_SIGWAIT] = (scall_func)(uintptr_t)sys_sigwait, + + [SYS_SOCKET] = (scall_func)(uintptr_t)net_socket, + [SYS_SETSOCKOPT] = (scall_func)(uintptr_t)net_setsockopt, + [SYS_BIND] = (scall_func)(uintptr_t)net_bind, + [SYS_ACCEPT] = (scall_func)(uintptr_t)net_accept, + [SYS_LISTEN] = (scall_func)(uintptr_t)net_listen, + [SYS_CONNECT] = (scall_func)(uintptr_t)net_connect, + [SYS_GETSOCKOPT] = (scall_func)(uintptr_t)net_getsockopt, + [SYS_RECV] = (scall_func)(uintptr_t)net_recv, + [SYS_SEND] = (scall_func)(uintptr_t)net_send, + [SYS_SHUTDOWN] = (scall_func)(uintptr_t)net_shutdown, }; static long num_syscalls = sizeof(syscalls) / sizeof(*syscalls); -typedef long (*scall_func)(); void syscall_handler(struct regs * r) { diff --git a/kernel/video/lfbvideo.c b/kernel/video/lfbvideo.c index 29d9680b..0cd8d9fd 100644 --- a/kernel/video/lfbvideo.c +++ b/kernel/video/lfbvideo.c @@ -348,7 +348,7 @@ static void graphics_install_bochs(uint16_t resolution_x, uint16_t resolution_y) finalize_graphics("bochs"); } -extern void arch_framebuffer_initialize(); +extern void arch_framebuffer_initialize(void); static void graphics_install_preset(uint16_t w, uint16_t h) { /* Make sure memsize is actually big enough */