diff --git a/fs/generic.c b/fs/generic.c index c46c688160..815b1683f4 100644 --- a/fs/generic.c +++ b/fs/generic.c @@ -81,7 +81,7 @@ int generic_getpath(struct fd *fd, char *buf) { return 0; } -int generic_accessat(struct fd *dirfd, const char *path_raw, int mode) { +int generic_accessat(struct fd *dirfd, const char *path_raw, int UNUSED(mode)) { char path[MAX_PATH]; int err = path_normalize(dirfd, path_raw, path, true); if (err < 0) diff --git a/fs/mem.c b/fs/mem.c index 483f89fced..3f52bd63ad 100644 --- a/fs/mem.c +++ b/fs/mem.c @@ -38,13 +38,13 @@ struct dev_ops mem_dev = { }; // begin inline devices -static int null_open(int major, int minor, int type, struct fd *fd) { +static int null_open(int UNUSED(major), int UNUSED(minor), int UNUSED(type), struct fd *UNUSED(fd)) { return 0; } -static ssize_t null_read(struct fd *fd, void *buf, size_t bufsize) { +static ssize_t null_read(struct fd *UNUSED(fd), void *UNUSED(buf), size_t UNUSED(bufsize)) { return 0; } -static ssize_t null_write(struct fd *fd, const void *buf, size_t bufsize) { +static ssize_t null_write(struct fd *UNUSED(fd), const void *UNUSED(buf), size_t bufsize) { return bufsize; } struct dev_ops null_dev = { @@ -53,11 +53,11 @@ struct dev_ops null_dev = { .fd.write = null_write, }; -static ssize_t zero_read(struct fd *fd, void *buf, size_t bufsize) { +static ssize_t zero_read(struct fd *UNUSED(fd), void *buf, size_t bufsize) { memset(buf, 0, bufsize); return bufsize; } -static ssize_t zero_write(struct fd *fd, const void *buf, size_t bufsize) { +static ssize_t zero_write(struct fd *UNUSED(fd), const void *UNUSED(buf), size_t bufsize) { return bufsize; } struct dev_ops zero_dev = { @@ -66,7 +66,7 @@ struct dev_ops zero_dev = { .fd.write = zero_write, }; -static ssize_t full_write(struct fd *fd, const void *buf, size_t bufsize) { +static ssize_t full_write(struct fd *UNUSED(fd), const void *UNUSED(buf), size_t UNUSED(bufsize)) { return _ENOSPC; } struct dev_ops full_dev = { @@ -75,7 +75,7 @@ struct dev_ops full_dev = { .fd.write = full_write, }; -static ssize_t random_read(struct fd *fd, void *buf, size_t bufsize) { +static ssize_t random_read(struct fd *UNUSED(fd), void *buf, size_t bufsize) { get_random(buf, bufsize); return bufsize; } diff --git a/fs/proc.c b/fs/proc.c index 5522d383be..343505337d 100644 --- a/fs/proc.c +++ b/fs/proc.c @@ -47,7 +47,7 @@ static int proc_lookup(const char *path, struct proc_entry *entry) { extern const struct fd_ops procfs_fdops; -static struct fd *proc_open(struct mount *mount, const char *path, int flags, int mode) { +static struct fd *proc_open(struct mount *UNUSED(mount), const char *path, int UNUSED(flags), int UNUSED(mode)) { struct proc_entry entry; int err = proc_lookup(path, &entry); if (err < 0) @@ -78,7 +78,7 @@ static int proc_getpath(struct fd *fd, char *buf) { return 0; } -static int proc_stat(struct mount *mount, const char *path, struct statbuf *stat, bool follow_links) { +static int proc_stat(struct mount *UNUSED(mount), const char *path, struct statbuf *stat, bool UNUSED(follow_links)) { struct proc_entry entry; int err = proc_lookup(path, &entry); if (err < 0) @@ -176,7 +176,7 @@ const struct fd_ops procfs_fdops = { .seekdir = proc_seekdir, }; -static ssize_t proc_readlink(struct mount *mount, const char *path, char *buf, size_t bufsize) { +static ssize_t proc_readlink(struct mount *UNUSED(mount), const char *path, char *buf, size_t bufsize) { struct proc_entry entry; int err = proc_lookup(path, &entry); if (err < 0) diff --git a/fs/proc/pid.c b/fs/proc/pid.c index a79e163378..9ee25000ab 100644 --- a/fs/proc/pid.c +++ b/fs/proc/pid.c @@ -15,7 +15,7 @@ static struct task *proc_get_task(struct proc_entry *entry) { unlock(&pids_lock); return task; } -static void proc_put_task(struct task *task) { +static void proc_put_task(struct task *UNUSED(task)) { unlock(&pids_lock); } diff --git a/fs/proc/root.c b/fs/proc/root.c index f29b731104..4d47d8b654 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -3,20 +3,20 @@ #include "fs/proc.h" #include "platform/platform.h" -static ssize_t proc_show_version(struct proc_entry *entry, char *buf) { +static ssize_t proc_show_version(struct proc_entry *UNUSED(entry), char *buf) { struct uname uts; do_uname(&uts); return sprintf(buf, "%s version %s %s\n", uts.system, uts.release, uts.version); } -static ssize_t proc_show_stat(struct proc_entry *entry, char *buf) { +static ssize_t proc_show_stat(struct proc_entry *UNUSED(entry), char *buf) { struct cpu_usage usage = get_cpu_usage(); size_t n = 0; n += sprintf(buf + n, "cpu %llu %llu %llu %llu\n", usage.user_ticks, usage.nice_ticks, usage.system_ticks, usage.idle_ticks); return n; } -static int proc_readlink_self(struct proc_entry *entry, char *buf) { +static int proc_readlink_self(struct proc_entry *UNUSED(entry), char *buf) { sprintf(buf, "%d/", current->pid); return 0; } @@ -29,7 +29,7 @@ struct proc_dir_entry proc_root_entries[] = { }; #define PROC_ROOT_LEN sizeof(proc_root_entries)/sizeof(proc_root_entries[0]) -static bool proc_root_readdir(struct proc_entry *entry, int *index, struct proc_entry *next_entry) { +static bool proc_root_readdir(struct proc_entry *UNUSED(entry), int *index, struct proc_entry *next_entry) { if (*index < PROC_ROOT_LEN) { *next_entry = (struct proc_entry) {&proc_root_entries[*index]}; (*index)++; diff --git a/fs/real.c b/fs/real.c index d62512af06..129fc419ca 100644 --- a/fs/real.c +++ b/fs/real.c @@ -273,7 +273,7 @@ static int realfs_symlink(struct mount *mount, const char *target, const char *l return err; } -static int realfs_mknod(struct mount *mount, const char *path, mode_t_ mode, dev_t_ dev) { +static int realfs_mknod(struct mount *mount, const char *path, mode_t_ mode, dev_t_ UNUSED(dev)) { int err; if (S_ISFIFO(mode)) { lock_fchdir(mount->root_fd); @@ -372,7 +372,7 @@ int realfs_flock(struct fd *fd, int operation) { return flock(fd->real_fd, real_op); } -int realfs_statfs(struct mount *mount, struct statfsbuf *stat) { +int realfs_statfs(struct mount *UNUSED(mount), struct statfsbuf *stat) { stat->namelen = NAME_MAX; stat->bsize = PAGE_SIZE; return 0; diff --git a/fs/tty-real.c b/fs/tty-real.c index 379c324c78..c0923f89c0 100644 --- a/fs/tty-real.c +++ b/fs/tty-real.c @@ -105,7 +105,7 @@ int real_tty_open(struct tty *tty) { return 0; } -ssize_t real_tty_write(struct tty *tty, const void *buf, size_t len) { +ssize_t real_tty_write(struct tty *UNUSED(tty), const void *buf, size_t len) { return write(STDOUT_FILENO, buf, len); } diff --git a/kernel/fs.c b/kernel/fs.c index 8fca985450..5e26347882 100644 --- a/kernel/fs.c +++ b/kernel/fs.c @@ -667,16 +667,18 @@ dword_t sys_fsync(fd_t f) { } // a few stubs -dword_t sys_sendfile(fd_t out_fd, fd_t in_fd, addr_t offset_addr, dword_t count) { +dword_t sys_sendfile(fd_t UNUSED(out_fd), fd_t UNUSED(in_fd), addr_t UNUSED(offset_addr), dword_t UNUSED(count)) { return _EINVAL; } -dword_t sys_sendfile64(fd_t out_fd, fd_t in_fd, addr_t offset_addr, dword_t count) { +dword_t sys_sendfile64(fd_t UNUSED(out_fd), fd_t UNUSED(in_fd), addr_t UNUSED(offset_addr), dword_t UNUSED(count)) { return _EINVAL; } -dword_t sys_copy_file_range(fd_t in_fd, addr_t in_off, fd_t out_fd, addr_t out_off, dword_t len, uint_t flags) { +dword_t sys_copy_file_range(fd_t UNUSED(in_fd), addr_t UNUSED(in_off), fd_t UNUSED(out_fd), + addr_t UNUSED(out_off), dword_t UNUSED(len), uint_t UNUSED(flags)) { return _EPERM; // good enough for ruby } -dword_t sys_xattr_stub(addr_t path_addr, addr_t name_addr, addr_t value_addr, dword_t size, dword_t flags) { +dword_t sys_xattr_stub(addr_t UNUSED(path_addr), addr_t UNUSED(name_addr), + addr_t UNUSED(value_addr), dword_t UNUSED(size), dword_t UNUSED(flags)) { return _ENOTSUP; } diff --git a/kernel/mmap.c b/kernel/mmap.c index af4bbc7b2d..f3145cf39b 100644 --- a/kernel/mmap.c +++ b/kernel/mmap.c @@ -155,16 +155,17 @@ int_t sys_mprotect(addr_t addr, uint_t len, int_t prot) { return err; } -dword_t sys_madvise(addr_t addr, dword_t len, dword_t advice) { +dword_t sys_madvise(addr_t UNUSED(addr), dword_t UNUSED(len), dword_t UNUSED(advice)) { // portable applications should not rely on linux's destructive semantics for MADV_DONTNEED. return 0; } -dword_t sys_mbind(addr_t addr, dword_t len, int_t mode, addr_t nodemask, dword_t maxnode, uint_t flags) { +dword_t sys_mbind(addr_t UNUSED(addr), dword_t UNUSED(len), int_t UNUSED(mode), + addr_t UNUSED(nodemask), dword_t UNUSED(maxnode), uint_t UNUSED(flags)) { return 0; } -int_t sys_mlock(addr_t addr, dword_t len) { +int_t sys_mlock(addr_t UNUSED(addr), dword_t UNUSED(len)) { return 0; } diff --git a/kernel/prctl.c b/kernel/prctl.c index 3c21b15f9e..70c810cb59 100644 --- a/kernel/prctl.c +++ b/kernel/prctl.c @@ -1,5 +1,5 @@ #include "kernel/calls.h" -int_t sys_prctl(dword_t option, uint_t arg2, uint_t arg3, uint_t arg4, uint_t arg5) { +int_t sys_prctl(dword_t UNUSED(option), uint_t UNUSED(arg2), uint_t UNUSED(arg3), uint_t UNUSED(arg4), uint_t UNUSED(arg5)) { return _EINVAL; } diff --git a/kernel/random.c b/kernel/random.c index 653bb015f9..c03aa9f29d 100644 --- a/kernel/random.c +++ b/kernel/random.c @@ -18,7 +18,7 @@ int get_random(char *buf, size_t len) { #endif } -dword_t sys_getrandom(addr_t buf_addr, dword_t len, dword_t flags) { +dword_t sys_getrandom(addr_t buf_addr, dword_t len, dword_t UNUSED(flags)) { if (len > 256) return _EIO; char buf[256]; diff --git a/kernel/signal.c b/kernel/signal.c index 2cdc9d0ec9..6a284fce53 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -225,7 +225,7 @@ void sighand_release(struct sighand *sighand) { } } -dword_t sys_rt_sigreturn(dword_t sig) { +dword_t sys_rt_sigreturn(dword_t UNUSED(sig)) { struct cpu_state *cpu = ¤t->cpu; struct sigframe_ frame; // skip the first two fields of the frame diff --git a/kernel/time.c b/kernel/time.c index 1cd214c412..d4ddad696d 100644 --- a/kernel/time.c +++ b/kernel/time.c @@ -68,7 +68,7 @@ dword_t sys_clock_getres(dword_t clock, addr_t res_addr) { return 0; } -dword_t sys_clock_settime(dword_t clock, addr_t tp) { +dword_t sys_clock_settime(dword_t UNUSED(clock), addr_t UNUSED(tp)) { return _EPERM; } @@ -177,7 +177,7 @@ dword_t sys_gettimeofday(addr_t tv, addr_t tz) { return 0; } -dword_t sys_settimeofday(addr_t tv, addr_t tz) { +dword_t sys_settimeofday(addr_t UNUSED(tv), addr_t UNUSED(tz)) { return _EPERM; } diff --git a/kernel/uname.c b/kernel/uname.c index 6898ec6cef..4a789b4263 100644 --- a/kernel/uname.c +++ b/kernel/uname.c @@ -28,7 +28,7 @@ dword_t sys_uname(addr_t uts_addr) { return 0; } -dword_t sys_sethostname(addr_t hostname_addr, dword_t hostname_len) { +dword_t sys_sethostname(addr_t UNUSED(hostname_addr), dword_t UNUSED(hostname_len)) { return _EPERM; } diff --git a/misc.h b/misc.h index 595a95be7d..dd3e22ef62 100644 --- a/misc.h +++ b/misc.h @@ -35,6 +35,7 @@ #else #define __no_instrument #endif +#define UNUSED(x) UNUSED_##x __attribute__((unused)) #if defined(__x86_64__) #define rdtsc() ({ \ diff --git a/tools/unicornomatic.c b/tools/unicornomatic.c index f8dc96efdb..de79fd4eda 100644 --- a/tools/unicornomatic.c +++ b/tools/unicornomatic.c @@ -333,12 +333,12 @@ void step_tracing(struct cpu_state *cpu, struct tlb *tlb, uc_engine *uc) { } } -static void uc_interrupt_callback(uc_engine *uc, uint32_t interrupt, void *user_data) { +static void uc_interrupt_callback(uc_engine *uc, uint32_t interrupt, void *UNUSED(user_data)) { uc_interrupt = interrupt; uc_emu_stop(uc); } -static bool uc_unmapped_callback(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data) { +static bool uc_unmapped_callback(uc_engine *uc, uc_mem_type UNUSED(type), uint64_t address, int size, int64_t UNUSED(value), void *UNUSED(user_data)) { struct pt_entry *pt = mem_pt(current->mem, PAGE(address)); // handle stack growing if (pt != NULL && pt->flags & P_GROWSDOWN) {