Skip to content

Commit

Permalink
Mark unused function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jan 6, 2019
1 parent b04f6f1 commit 032a218
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion fs/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions fs/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions fs/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)++;
Expand Down
4 changes: 2 additions & 2 deletions fs/real.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fs/tty-real.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 6 additions & 4 deletions kernel/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 4 additions & 3 deletions kernel/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/prctl.c
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion kernel/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = &current->cpu;
struct sigframe_ frame;
// skip the first two fields of the frame
Expand Down
4 changes: 2 additions & 2 deletions kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/uname.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#else
#define __no_instrument
#endif
#define UNUSED(x) UNUSED_##x __attribute__((unused))

#if defined(__x86_64__)
#define rdtsc() ({ \
Expand Down
4 changes: 2 additions & 2 deletions tools/unicornomatic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 032a218

Please sign in to comment.