Merge pull request #2728 from saagarjha/master

Fix a bunch of warnings
This commit is contained in:
Saagar Jha
2026-05-03 05:22:27 -07:00
committed by GitHub
31 changed files with 70 additions and 66 deletions
+2 -2
View File
@@ -462,7 +462,7 @@ static inline uint16_t cpu_reg_offset(enum arg arg, int index) {
return 0;
}
static inline bool gen_vec(enum arg src, enum arg dst, void (*helper)(), gadget_t read_mem_gadget, gadget_t write_mem_gadget, struct gen_state *state, struct modrm *modrm, uint8_t imm, bool seg_gs, bool has_imm) {
static inline bool gen_vec(enum arg src, enum arg dst, void (*helper)(void), gadget_t read_mem_gadget, gadget_t write_mem_gadget, struct gen_state *state, struct modrm *modrm, uint8_t imm, bool seg_gs, bool has_imm) {
bool rm_is_src = !could_be_memory(dst);
enum arg rm = rm_is_src ? src : dst;
enum arg reg = rm_is_src ? dst : src;
@@ -523,7 +523,7 @@ static inline bool gen_vec(enum arg src, enum arg dst, void (*helper)(), gadget_
#define _v(src, dst, helper, _imm, z) do { \
extern void gadget_vec_helper_read##z##_imm(void); \
extern void gadget_vec_helper_write##z##_imm(void); \
if (!gen_vec(src, dst, (void (*)()) helper, gadget_vec_helper_read##z##_imm, gadget_vec_helper_write##z##_imm, state, &modrm, imm, seg_gs, has_imm_##_imm)) return false; \
if (!gen_vec(src, dst, (void (*)(void)) helper, gadget_vec_helper_read##z##_imm, gadget_vec_helper_write##z##_imm, state, &modrm, imm, seg_gs, has_imm_##_imm)) return false; \
} while (0)
#define v_(op, src, dst, _imm,z) _v(arg_##src, arg_##dst, vec_##op##z, _imm,z)
#define v(op, src, dst,z) v_(op, src, dst,,z)
+1 -1
View File
@@ -3,7 +3,7 @@
#include "emu/cpu.h"
#include "emu/tlb.h"
void cpu() {
void cpu(void) {
OFFSET(CPU, cpu_state, eax);
OFFSET(CPU, cpu_state, ebx);
OFFSET(CPU, cpu_state, ecx);
+6 -6
View File
@@ -69,7 +69,7 @@ void assertf(int cond, const char *msg, ...) {
puts(buf);
}
void test_int_convert() {
void test_int_convert(void) {
suite_start();
union f80 u;
int64_t i;
@@ -96,7 +96,7 @@ void test_int_convert() {
suite_end();
}
void test_double_convert() {
void test_double_convert(void) {
suite_start();
union f80 u;
double d;
@@ -118,7 +118,7 @@ void test_double_convert() {
suite_end();
}
void test_round() {
void test_round(void) {
suite_start();
union f80 u, ur;
long double r;
@@ -145,7 +145,7 @@ void test_round() {
suite_end();
}
void test_math() {
void test_math(void) {
suite_start();
union f80 ua, ub, u;
long double expected;
@@ -217,7 +217,7 @@ void test_math() {
suite_end();
}
void test_compare() {
void test_compare(void) {
suite_start();
union f80 ua, ub;
bool expected, actual;
@@ -258,7 +258,7 @@ uint64_t fnmulh(uint64_t a, uint64_t b) {
return ((unsigned __int128) a * b) >> 64;
}
int main() {
int main(void) {
for (int rounding_mode = 0; rounding_mode < 4; rounding_mode++) {
f80_rounding_mode = rounding_mode;
switch (rounding_mode) {
+2
View File
@@ -297,6 +297,7 @@ static bool cmpd(double a, double b, int type) {
case 1: res = a < b; break;
case 2: res = a <= b; break;
case 3: res = isnan(a) || isnan(b); break;
default: __builtin_unreachable();
}
if (type >= 4) res = !res;
return res;
@@ -308,6 +309,7 @@ static bool cmps(float a, float b, int type) {
case 1: res = a < b; break;
case 2: res = a <= b; break;
case 3: res = isnan(a) || isnan(b); break;
default: __builtin_unreachable();
}
if (type >= 4) res = !res;
return res;
+1 -1
View File
@@ -354,7 +354,7 @@ retry:
}
static struct fd_ops fakefs_fdops;
static void __attribute__((constructor)) init_fake_fdops() {
static void __attribute__((constructor)) init_fake_fdops(void) {
fakefs_fdops = realfs_fdops;
fakefs_fdops.readdir = fakefs_readdir;
}
+1 -1
View File
@@ -37,7 +37,7 @@ static int real_poll_update(struct real_poll *real, int fd, int types, void *dat
// lock order: fd, then poll
struct poll *poll_create() {
struct poll *poll_create(void) {
struct poll *poll = malloc(sizeof(struct poll));
if (poll == NULL)
return ERR_PTR(_ENOMEM);
+1 -1
View File
@@ -128,7 +128,7 @@ const struct tty_driver_ops pty_slave_ops = {
};
DEFINE_TTY_DRIVER(pty_slave, &pty_slave_ops, TTY_PSEUDO_SLAVE_MAJOR, MAX_PTYS);
static int pty_reserve_next() {
static int pty_reserve_next(void) {
int pty_num;
lock(&ttys_lock);
for (pty_num = 0; pty_num < MAX_PTYS; pty_num++) {
+3
View File
@@ -33,6 +33,8 @@ static int getpath(int fd, char *buf) {
#endif
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
static int open_flags_real_from_fake(int flags) {
int real_flags = 0;
if (flags & O_RDONLY_) real_flags |= O_RDONLY;
@@ -58,6 +60,7 @@ static int open_flags_fake_from_real(int flags) {
if (flags & O_NONBLOCK) fake_flags |= O_NONBLOCK_;
return fake_flags;
}
#pragma clang diagnostic pop
struct fd *realfs_open(struct mount *mount, const char *path, int flags, int mode) {
int real_flags = open_flags_real_from_fake(flags);
+2 -2
View File
@@ -78,7 +78,7 @@ static struct fd *sock_getfd(fd_t sock_fd) {
return sock;
}
static uint32_t unix_socket_next_id() {
static uint32_t unix_socket_next_id(void) {
static uint32_t next_id = 0;
static lock_t next_id_lock = LOCK_INITIALIZER;
lock(&next_id_lock);
@@ -1186,7 +1186,7 @@ const struct fd_ops socket_fdops = {
.ioctl = realfs_ioctl,
};
#if defined(__GNUC__) && __GNUC__ >= 8
#if is_gcc(8) || is_clang(21)
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
#if defined(__clang__)
+3 -3
View File
@@ -49,7 +49,7 @@ void sockrestart_end_listen_wait(struct fd *sock) {
unlock(&sockrestart_lock);
}
bool sockrestart_should_restart_listen_wait() {
bool sockrestart_should_restart_listen_wait(void) {
lock(&sockrestart_lock);
bool punt = current->sockrestart.punt;
current->sockrestart.punt = false;
@@ -73,7 +73,7 @@ static struct list saved_sockets = LIST_INITIALIZER(saved_sockets);
// these should only be called from the main thread, but it's easiest to just lock for the whole time
void sockrestart_on_suspend() {
void sockrestart_on_suspend(void) {
lock(&sockrestart_lock);
assert(list_empty(&saved_sockets));
struct fd *sock;
@@ -93,7 +93,7 @@ void sockrestart_on_suspend() {
unlock(&sockrestart_lock);
}
void sockrestart_on_resume() {
void sockrestart_on_resume(void) {
lock(&sockrestart_lock);
struct saved_socket *saved, *tmp;
list_for_each_entry_safe(&saved_sockets, saved, tmp, saved) {
-1
View File
@@ -95,7 +95,6 @@ dword_t sys_fstat64(fd_t fd_no, addr_t statbuf_addr) {
}
dword_t sys_statx(fd_t at_f, addr_t path_addr, int_t flags, uint_t mask, addr_t statx_addr) {
int err;
char path[MAX_PATH];
if (user_read_string(path_addr, path, sizeof(path)))
return _EFAULT;
+1 -1
View File
@@ -125,7 +125,7 @@ static int real_tty_write(struct tty *tty, const void *buf, size_t len, bool UNU
return write(STDOUT_FILENO, buf, len);
}
void real_tty_reset_term() {
void real_tty_reset_term(void) {
if (!real_tty_is_open) return;
if (tcsetattr(STDIN_FILENO, TCSANOW, &old_termios) < 0 && errno != ENOTTY) {
printk("failed to reset terminal: %s\n", strerror(errno));
+1 -1
View File
@@ -19,7 +19,7 @@ dword_t syscall_success_stub(void) {
return 0;
}
#if is_gcc(8)
#if is_gcc(8) || is_clang(21)
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
syscall_t syscall_table[] = {
+1 -1
View File
@@ -17,7 +17,7 @@ fd_t sys_epoll_create(int_t flags) {
fd->epollfd.poll = poll;
return f_install(fd, flags);
}
fd_t sys_epoll_create0() {
fd_t sys_epoll_create0(void) {
return sys_epoll_create(0);
}
+1 -1
View File
@@ -98,7 +98,7 @@ int err_map(int err) {
return -(err | 0x1000);
}
int errno_map() {
int errno_map(void) {
if (errno == EPIPE)
send_signal(current, SIGPIPE_, SIGINFO_NIL);
return err_map(errno);
+2 -2
View File
@@ -196,11 +196,11 @@ dword_t sys_clone(dword_t flags, addr_t stack, addr_t ptid, addr_t tls, addr_t c
return pid;
}
dword_t sys_fork() {
dword_t sys_fork(void) {
return sys_clone(SIGCHLD_, 0, 0, 0, 0);
}
dword_t sys_vfork() {
dword_t sys_vfork(void) {
return sys_clone(CLONE_VFORK_ | CLONE_VM_ | SIGCHLD_, 0, 0, 0, 0);
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "kernel/fs.h"
#include "fs/fd.h"
struct fs_info *fs_info_new() {
struct fs_info *fs_info_new(void) {
struct fs_info *fs = malloc(sizeof(struct fs_info));
if (fs == NULL)
return NULL;
+1 -1
View File
@@ -25,7 +25,7 @@ struct futex_wait {
static lock_t futex_lock = LOCK_INITIALIZER;
static struct list futex_hash[FUTEX_HASH_SIZE];
static void __attribute__((constructor)) init_futex_hash() {
static void __attribute__((constructor)) init_futex_hash(void) {
for (int i = 0; i < FUTEX_HASH_SIZE; i++)
list_init(&futex_hash[i]);
}
+11 -11
View File
@@ -2,15 +2,15 @@
#include "kernel/task.h"
#include "kernel/personality.h"
pid_t_ sys_getpid() {
pid_t_ sys_getpid(void) {
STRACE("getpid()");
return current->tgid;
}
pid_t_ sys_gettid() {
pid_t_ sys_gettid(void) {
STRACE("gettid()");
return current->pid;
}
pid_t_ sys_getppid() {
pid_t_ sys_getppid(void) {
STRACE("getppid()");
pid_t_ ppid;
lock(&pids_lock);
@@ -22,20 +22,20 @@ pid_t_ sys_getppid() {
return ppid;
}
dword_t sys_getuid32() {
dword_t sys_getuid32(void) {
STRACE("getuid32()");
return current->uid;
}
dword_t sys_getuid() {
dword_t sys_getuid(void) {
STRACE("getuid()");
return current->uid & 0xffff;
}
dword_t sys_geteuid32() {
dword_t sys_geteuid32(void) {
STRACE("geteuid32()");
return current->euid;
}
dword_t sys_geteuid() {
dword_t sys_geteuid(void) {
STRACE("geteuid()");
return current->euid & 0xffff;
}
@@ -87,20 +87,20 @@ int_t sys_setreuid(uid_t_ ruid, uid_t_ euid) {
return sys_setresuid(ruid, euid, -1);
}
dword_t sys_getgid32() {
dword_t sys_getgid32(void) {
STRACE("getgid32()");
return current->gid;
}
dword_t sys_getgid() {
dword_t sys_getgid(void) {
STRACE("getgid()");
return current->gid & 0xffff;
}
dword_t sys_getegid32() {
dword_t sys_getegid32(void) {
STRACE("getegid32()");
return current->egid;
}
dword_t sys_getegid() {
dword_t sys_getegid(void) {
STRACE("getegid()");
return current->egid & 0xffff;
}
+4 -4
View File
@@ -55,7 +55,7 @@ out:
return err;
}
dword_t sys_setpgrp() {
dword_t sys_setpgrp(void) {
return sys_setpgid(0, 0);
}
@@ -73,7 +73,7 @@ pid_t_ sys_getpgid(pid_t_ pid) {
unlock(&pids_lock);
return pid;
}
pid_t_ sys_getpgrp() {
pid_t_ sys_getpgrp(void) {
return sys_getpgid(0);
}
@@ -116,12 +116,12 @@ pid_t_ task_setsid(struct task *task) {
return new_sid;
}
dword_t sys_setsid() {
dword_t sys_setsid(void) {
STRACE("setsid()");
return task_setsid(current);
}
dword_t sys_getsid() {
dword_t sys_getsid(void) {
STRACE("getsid()");
lock(&pids_lock);
pid_t_ sid = current->group->sid;
+4 -4
View File
@@ -19,7 +19,7 @@ int mount_root(const struct fs_ops *fs, const char *source) {
return 0;
}
static void establish_signal_handlers() {
static void establish_signal_handlers(void) {
extern void sigusr1_handler(int sig);
struct sigaction sigact;
sigact.sa_handler = sigusr1_handler;
@@ -86,7 +86,7 @@ static struct task *construct_task(struct task *parent) {
return task;
}
int become_first_process() {
int become_first_process(void) {
// now seems like a nice time
establish_signal_handlers();
@@ -98,7 +98,7 @@ int become_first_process() {
return 0;
}
int become_new_init_child() {
int become_new_init_child(void) {
// locking? who needs locking?!
struct task *init = pid_get_task(1);
assert(init != NULL);
@@ -155,7 +155,7 @@ static struct fd *open_fd_from_actual_fd(int fd_no) {
return fd;
}
int create_piped_stdio() {
int create_piped_stdio(void) {
if (!(current->files->files[0] = open_fd_from_actual_fd(STDIN_FILENO))) {
return -1;
}
+1 -1
View File
@@ -176,7 +176,7 @@ void die(const char *msg, ...) {
}
// fun little utility function
int current_pid() {
int current_pid(void) {
if (current)
return current->pid;
return -1;
+2 -3
View File
@@ -7,7 +7,7 @@
#include "kernel/memory.h"
#include "kernel/mm.h"
struct mm *mm_new() {
struct mm *mm_new(void) {
struct mm *mm = malloc(sizeof(struct mm));
if (mm == NULL)
return NULL;
@@ -59,8 +59,7 @@ static addr_t do_mmap(addr_t addr, dword_t len, dword_t prot, dword_t flags, fd_
if (!(flags & MMAP_FIXED) && !pt_is_hole(current->mem, page, pages)) {
addr = 0;
}
}
if (addr == 0) {
} else {
page = pt_find_hole(current->mem, pages);
if (page == BAD_PAGE)
return _ENOMEM;
+1 -1
View File
@@ -136,7 +136,7 @@ dword_t sys_prlimit64(pid_t_ pid, dword_t resource, addr_t new_limit_addr, addr_
return 0;
}
struct rusage_ rusage_get_current() {
struct rusage_ rusage_get_current(void) {
// only the time fields are currently implemented
struct rusage_ rusage;
#if __linux__
+6 -6
View File
@@ -324,7 +324,7 @@ void signal_delivery_stop(int sig, struct siginfo_ *info) {
lock(&current->sighand->lock);
}
void receive_signals() {
void receive_signals(void) {
lock(&current->group->lock);
bool was_stopped = current->group->stopped;
unlock(&current->group->lock);
@@ -397,7 +397,7 @@ static void restore_sigcontext(struct sigcontext_ *context, struct cpu_state *cp
cpu->eflags = (context->flags & USE_FLAGS) | (cpu->eflags & ~USE_FLAGS);
}
dword_t sys_rt_sigreturn() {
dword_t sys_rt_sigreturn(void) {
struct cpu_state *cpu = &current->cpu;
struct rt_sigframe_ frame;
// esp points past the first field of the frame
@@ -419,7 +419,7 @@ dword_t sys_rt_sigreturn() {
return cpu->eax;
}
dword_t sys_sigreturn() {
dword_t sys_sigreturn(void) {
struct cpu_state *cpu = &current->cpu;
struct sigframe_ frame;
// esp points past the first two fields of the frame
@@ -436,7 +436,7 @@ dword_t sys_sigreturn() {
return cpu->eax;
}
struct sighand *sighand_new() {
struct sighand *sighand_new(void) {
struct sighand *sighand = malloc(sizeof(struct sighand));
if (sighand == NULL)
return NULL;
@@ -535,7 +535,7 @@ dword_t sys_rt_sigprocmask(dword_t how, addr_t set_addr, addr_t oldset_addr, dwo
if (size != sizeof(sigset_t_))
return _EINVAL;
sigset_t_ set;
sigset_t_ set = 0;
if (set_addr != 0)
if (user_get(set_addr, set))
return _EFAULT;
@@ -634,7 +634,7 @@ int_t sys_rt_sigsuspend(addr_t mask_addr, uint_t size) {
return _EINTR;
}
int_t sys_pause() {
int_t sys_pause(void) {
lock(&current->sighand->lock);
while (wait_for(&current->pause, &current->sighand->lock, NULL) != _EINTR)
continue;
+4 -4
View File
@@ -95,7 +95,7 @@ void task_destroy(struct task *task) {
free(task);
}
void task_run_current() {
void task_run_current(void) {
struct cpu_state *cpu = &current->cpu;
struct tlb tlb = {};
tlb_refresh(&tlb, &current->mem->mmu);
@@ -115,7 +115,7 @@ static void *task_thread(void *task) {
}
static pthread_attr_t task_thread_attr;
__attribute__((constructor)) static void create_attr() {
__attribute__((constructor)) static void create_attr(void) {
pthread_attr_init(&task_thread_attr);
pthread_attr_setdetachstate(&task_thread_attr, PTHREAD_CREATE_DETACHED);
}
@@ -125,13 +125,13 @@ void task_start(struct task *task) {
die("could not create thread");
}
int_t sys_sched_yield() {
int_t sys_sched_yield(void) {
STRACE("sched_yield()");
sched_yield();
return 0;
}
void update_thread_name() {
void update_thread_name(void) {
char name[16]; // As long as Linux will let us make this
snprintf(name, sizeof(name), "-%d", current->pid);
size_t pid_width = strlen(name);
+1 -1
View File
@@ -41,7 +41,7 @@ dword_t sys_sethostname(addr_t UNUSED(hostname_addr), dword_t UNUSED(hostname_le
}
#if __APPLE__
static uint64_t get_total_ram() {
static uint64_t get_total_ram(void) {
uint64_t total_ram;
sysctl((int []) {CTL_DEBUG, HW_PHYSMEM}, 2, &total_ram, NULL, NULL, 0);
return total_ram;
+1
View File
@@ -22,6 +22,7 @@
// compiler check
#define is_gcc(version) (__GNUC__ >= version)
#define is_clang(version) (__clang_major__ >= version)
#if !defined(__has_attribute)
#define has_attribute(x) 0
+3 -3
View File
@@ -3,7 +3,7 @@
#include <sys/time.h>
#include "platform/platform.h"
struct cpu_usage get_cpu_usage() {
struct cpu_usage get_cpu_usage(void) {
host_cpu_load_info_data_t load;
mach_msg_type_number_t fuck = HOST_CPU_LOAD_INFO_COUNT;
host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t) &load, &fuck);
@@ -15,7 +15,7 @@ struct cpu_usage get_cpu_usage() {
return usage;
}
struct mem_usage get_mem_usage() {
struct mem_usage get_mem_usage(void) {
host_basic_info_data_t basic = {};
mach_msg_type_number_t fuck = HOST_BASIC_INFO_COUNT;
kern_return_t status = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t) &basic, &fuck);
@@ -33,7 +33,7 @@ struct mem_usage get_mem_usage() {
return usage;
}
struct uptime_info get_uptime() {
struct uptime_info get_uptime(void) {
uint64_t kern_boottime[2];
size_t size = sizeof(kern_boottime);
sysctlbyname("kern.boottime", &kern_boottime, &size, NULL, 0);
+1 -1
View File
@@ -1,4 +1,4 @@
// temporarily change directory and block other threads from doing so
// useful for simulating mknodat on ios, dealing with long unix socket paths, etc
void lock_fchdir(int dirfd);
void unlock_fchdir();
void unlock_fchdir(void);
+1 -1
View File
@@ -95,7 +95,7 @@ void notify_once(cond_t *cond) {
__thread sigjmp_buf unwind_buf;
__thread bool should_unwind = false;
void sigusr1_handler() {
void sigusr1_handler(void) {
if (should_unwind) {
should_unwind = false;
siglongjmp(unwind_buf, 1);