Skip to content

Commit

Permalink
Resolve -Wsign-compare
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jan 6, 2019
1 parent 1b22ddb commit 89d5b7f
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 80 deletions.
4 changes: 2 additions & 2 deletions fs/fake.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static int fakefs_mount(struct mount *mount) {
ino_t db_inode = statbuf.st_ino;
statement = db_prepare(mount, "select db_inode from meta");
if (sqlite3_step(statement) == SQLITE_ROW) {
if (sqlite3_column_int64(statement, 0) != db_inode) {
if ((uint64_t) sqlite3_column_int64(statement, 0) != db_inode) {
sqlite3_finalize(statement);
statement = NULL;
int err = fakefs_rebuild(mount);
Expand All @@ -459,7 +459,7 @@ static int fakefs_mount(struct mount *mount) {

// save current inode
statement = db_prepare(mount, "update meta set db_inode = ?");
sqlite3_bind_int64(statement, 1, db_inode);
sqlite3_bind_int64(statement, 1, (int64_t) db_inode);
db_check_error(mount);
sqlite3_step(statement);
db_check_error(mount);
Expand Down
14 changes: 7 additions & 7 deletions fs/fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ int fd_close(struct fd *fd) {
return err;
}

static int fdtable_resize(struct fdtable *table, unsigned size);
static int fdtable_resize(struct fdtable *table, int size);

struct fdtable *fdtable_new(unsigned size) {
struct fdtable *fdtable_new(int size) {
struct fdtable *fdt = malloc(sizeof(struct fdtable));
if (fdt == NULL)
return ERR_PTR(_ENOMEM);
Expand Down Expand Up @@ -81,7 +81,7 @@ void fdtable_release(struct fdtable *table) {
}
}

static int fdtable_resize(struct fdtable *table, unsigned size) {
static int fdtable_resize(struct fdtable *table, int size) {
// currently the only legitimate use of this is to expand the table
assert(size > table->size);

Expand Down Expand Up @@ -111,7 +111,7 @@ static int fdtable_resize(struct fdtable *table, unsigned size) {

struct fdtable *fdtable_copy(struct fdtable *table) {
lock(&table->lock);
unsigned size = table->size;
int size = table->size;
struct fdtable *new_table = fdtable_new(size);
if (IS_ERR(new_table)) {
unlock(&table->lock);
Expand All @@ -127,10 +127,10 @@ struct fdtable *fdtable_copy(struct fdtable *table) {
}

static int fdtable_expand(struct fdtable *table, fd_t max) {
unsigned size = max + 1;
int size = max + 1;
if (table->size >= size)
return 0;
if (size > rlimit(RLIMIT_NOFILE_))
if (size > (int) rlimit(RLIMIT_NOFILE_))
return _EMFILE;
return fdtable_resize(table, max + 1);
}
Expand All @@ -151,7 +151,7 @@ struct fd *f_get(fd_t f) {

static fd_t f_install_start(struct fd *fd, fd_t start) {
struct fdtable *table = current->files;
unsigned size = rlimit(RLIMIT_NOFILE_);
int size = rlimit(RLIMIT_NOFILE_);
if (size > table->size)
size = table->size;

Expand Down
6 changes: 3 additions & 3 deletions fs/fd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct fd {
// proc
struct {
struct proc_entry proc_entry;
int proc_dir_index;
unsigned proc_dir_index;
char *proc_data;
size_t proc_size;
};
Expand Down Expand Up @@ -116,13 +116,13 @@ struct fd_ops {

struct fdtable {
atomic_uint refcount;
unsigned size;
int size;
struct fd **files;
bits_t *cloexec;
lock_t lock;
};

struct fdtable *fdtable_new(unsigned size);
struct fdtable *fdtable_new(int size);
void fdtable_release(struct fdtable *table);
struct fdtable *fdtable_copy(struct fdtable *table);
void fdtable_free(struct fdtable *table);
Expand Down
4 changes: 2 additions & 2 deletions fs/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int proc_lookup(const char *path, struct proc_entry *entry) {
}
*c = '\0';

int index = 0;
unsigned index = 0;
struct proc_entry next_entry;
char entry_name[MAX_NAME];
while (proc_dir_read(entry, &index, &next_entry)) {
Expand Down Expand Up @@ -116,7 +116,7 @@ static ssize_t proc_read(struct fd *fd, void *buf, size_t bufsize) {
assert(data != NULL);

size_t remaining = fd->proc_size - fd->offset;
if (fd->offset > fd->proc_size)
if ((size_t) fd->offset > fd->proc_size)
remaining = 0;
size_t n = bufsize;
if (n > remaining)
Expand Down
4 changes: 2 additions & 2 deletions fs/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct proc_dir_entry {
size_t children_sizeof;

// directory with dynamic contents
bool (*readdir)(struct proc_entry *entry, int *index, struct proc_entry *next_entry);
bool (*readdir)(struct proc_entry *entry, unsigned *index, struct proc_entry *next_entry);

struct proc_dir_entry *parent;
int inode;
Expand All @@ -42,6 +42,6 @@ mode_t_ proc_entry_mode(struct proc_entry *entry);
void proc_entry_getname(struct proc_entry *entry, char *buf);
int proc_entry_stat(struct proc_entry *entry, struct statbuf *stat);

bool proc_dir_read(struct proc_entry *entry, int *index, struct proc_entry *next_entry);
bool proc_dir_read(struct proc_entry *entry, unsigned *index, struct proc_entry *next_entry);

#endif
2 changes: 1 addition & 1 deletion fs/proc/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void proc_entry_getname(struct proc_entry *entry, char *buf) {
assert(!"missing name in proc entry");
}

bool proc_dir_read(struct proc_entry *entry, int *index, struct proc_entry *next_entry) {
bool proc_dir_read(struct proc_entry *entry, unsigned *index, struct proc_entry *next_entry) {
if (entry->meta->readdir)
return entry->meta->readdir(entry, index, next_entry);

Expand Down
4 changes: 2 additions & 2 deletions fs/proc/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ static ssize_t proc_pid_cmdline_show(struct proc_entry *entry, char *buf) {

static struct proc_dir_entry proc_pid_fd;

static bool proc_pid_fd_readdir(struct proc_entry *entry, int *index, struct proc_entry *next_entry) {
static bool proc_pid_fd_readdir(struct proc_entry *entry, unsigned *index, struct proc_entry *next_entry) {
struct task *task = proc_get_task(entry);
if (task == NULL)
return _ESRCH;
lock(&task->files->lock);
while (*index < task->files->size && task->files->files[*index] == NULL)
while ((int) *index < task->files->size && task->files->files[*index] == NULL)
(*index)++;
fd_t f = (*index)++;
bool any_left = f < task->files->size;
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *UNUSED(entry), int *index, struct proc_entry *next_entry) {
static bool proc_root_readdir(struct proc_entry *UNUSED(entry), unsigned *index, struct proc_entry *next_entry) {
if (*index < PROC_ROOT_LEN) {
*next_entry = (struct proc_entry) {&proc_root_entries[*index], 0, 0};
(*index)++;
Expand Down
2 changes: 1 addition & 1 deletion fs/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ dword_t sys_recvmsg(fd_t sock_fd, addr_t msghdr_addr, dword_t flags) {
if (user_get(msg_fake.msg_iov, msg_iov_fake))
return _EFAULT;

for (int i = 0; i < msg_fake.msg_iovlen; i++) {
for (uint_t i = 0; i < msg_fake.msg_iovlen; i++) {
char iov_base[msg_iov_fake[i].iov_len];
memset(&iov_base, 0, sizeof(iov_base));

Expand Down
8 changes: 4 additions & 4 deletions fs/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static void tty_read_into_buf(struct tty *tty, void *buf, size_t bufsize) {
memmove(tty->buf_flag, tty->buf_flag + bufsize, tty->bufsize);
}

static ssize_t tty_canon_size(struct tty *tty) {
static size_t tty_canon_size(struct tty *tty) {
bool *flag_ptr = memchr(tty->buf_flag, true, tty->bufsize);
if (flag_ptr == NULL)
return -1;
Expand All @@ -281,8 +281,8 @@ static ssize_t tty_read(struct fd *fd, void *buf, size_t bufsize) {
struct tty *tty = fd->tty;
lock(&tty->lock);
if (tty->termios.lflags & ICANON_) {
ssize_t canon_size = -1;
while ((canon_size = tty_canon_size(tty)) == -1) {
size_t canon_size = -1;
while ((canon_size = tty_canon_size(tty)) == (size_t) -1) {
if (wait_for(&tty->produced, &tty->lock, NULL))
goto eintr;
}
Expand Down Expand Up @@ -351,7 +351,7 @@ static int tty_poll(struct fd *fd) {
lock(&tty->lock);
int types = POLL_WRITE;
if (tty->termios.lflags & ICANON_) {
if (tty_canon_size(tty) != -1)
if (tty_canon_size(tty) != (size_t) -1)
types |= POLL_READ;
} else {
if (tty->bufsize > 0)
Expand Down
4 changes: 2 additions & 2 deletions fs/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ struct tty {
int type;
int num;

dword_t session;
dword_t fg_group;
pid_t_ session;
pid_t_ fg_group;

struct list fds;
// only locks fds, to keep the lock order
Expand Down
2 changes: 1 addition & 1 deletion jit/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void cpu_run(struct cpu_state *cpu) {

int i = 0;
read_wrlock(&cpu->mem->lock);
int changes = cpu->mem->changes;
unsigned changes = cpu->mem->changes;

while (true) {
addr_t ip = frame.cpu.eip;
Expand Down
30 changes: 15 additions & 15 deletions kernel/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct pollfd_ {
word_t events;
word_t revents;
};
dword_t sys_poll(addr_t fds, dword_t nfds, dword_t timeout);
dword_t sys_poll(addr_t fds, dword_t nfds, int_t timeout);
dword_t sys_select(fd_t nfds, addr_t readfds_addr, addr_t writefds_addr, addr_t exceptfds_addr, addr_t timeout_addr);
dword_t sys_pselect(fd_t nfds, addr_t readfds_addr, addr_t writefds_addr, addr_t exceptfds_addr, addr_t timeout_addr, addr_t sigmask_addr);
dword_t sys_ppoll(addr_t fds, dword_t nfds, addr_t timeout_addr, addr_t sigmask_addr, dword_t sigsetsize);
Expand Down Expand Up @@ -154,23 +154,23 @@ dword_t sys_umount2(addr_t target_addr, dword_t flags);
dword_t sys_xattr_stub(addr_t path_addr, addr_t name_addr, addr_t value_addr, dword_t size, dword_t flags);

// process information
dword_t sys_getpid(void);
dword_t sys_gettid(void);
dword_t sys_getppid(void);
dword_t sys_getpgid(dword_t pid);
dword_t sys_setpgid(dword_t pid, dword_t pgid);
dword_t sys_getpgrp(void);
pid_t_ sys_getpid(void);
pid_t_ sys_gettid(void);
pid_t_ sys_getppid(void);
pid_t_ sys_getpgid(pid_t_ pid);
dword_t sys_setpgid(pid_t_ pid, pid_t_ pgid);
pid_t_ sys_getpgrp(void);
dword_t sys_setpgrp(void);
dword_t sys_getuid32(void);
dword_t sys_getuid(void);
uid_t_ sys_getuid32(void);
uid_t_ sys_getuid(void);
int_t sys_setuid(uid_t uid);
dword_t sys_geteuid32(void);
dword_t sys_geteuid(void);
uid_t_ sys_geteuid32(void);
uid_t_ sys_geteuid(void);
int_t sys_setgid(uid_t gid);
dword_t sys_getgid32(void);
dword_t sys_getgid(void);
dword_t sys_getegid32(void);
dword_t sys_getegid(void);
uid_t_ sys_getgid32(void);
uid_t_ sys_getgid(void);
uid_t_ sys_getegid32(void);
uid_t_ sys_getegid(void);
dword_t sys_setresuid(uid_t_ ruid, uid_t_ euid, uid_t_ suid);
dword_t sys_setresgid(uid_t_ rgid, uid_t_ egid, uid_t_ sgid);
int_t sys_getresuid(addr_t ruid_addr, addr_t euid_addr, addr_t suid_addr);
Expand Down
18 changes: 9 additions & 9 deletions kernel/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ dword_t sys_readv(fd_t fd_no, addr_t iovec_addr, dword_t iovec_count) {
struct io_vec *iovecs = malloc(iovec_size);
if (iovecs == NULL)
return _ENOMEM;
dword_t res = 0;
int res = 0;
if (user_read(iovec_addr, iovecs, iovec_size)) {
res = _EFAULT;
goto err;
Expand All @@ -210,7 +210,7 @@ dword_t sys_readv(fd_t fd_no, addr_t iovec_addr, dword_t iovec_count) {
if (res < 0)
goto err;
count += res;
if (res < iovecs[i].len)
if ((unsigned) res < iovecs[i].len)
break;
}
free(iovecs);
Expand Down Expand Up @@ -259,7 +259,7 @@ dword_t sys_writev(fd_t fd_no, addr_t iovec_addr, dword_t iovec_count) {
if (res < 0)
goto err;
count += res;
if (res < iovecs[i].len)
if ((unsigned) res < iovecs[i].len)
break;
}
free(iovecs);
Expand Down Expand Up @@ -553,17 +553,17 @@ dword_t sys_chmod(addr_t path_addr, dword_t mode) {
return sys_fchmodat(AT_FDCWD_, path_addr, mode, 0);
}

dword_t sys_fchown32(fd_t f, dword_t owner, dword_t group) {
dword_t sys_fchown32(fd_t f, uid_t_ owner, uid_t_ group) {
struct fd *fd = f_get(f);
if (fd == NULL)
return _EBADF;
int err;
if (owner != -1) {
if (owner != (uid_t) -1) {
err = fd->mount->fs->fsetattr(fd, make_attr(uid, owner));
if (err < 0)
return err;
}
if (group != -1) {
if (group != (uid_t) -1) {
err = fd->mount->fs->fsetattr(fd, make_attr(gid, group));
if (err < 0)
return err;
Expand All @@ -581,12 +581,12 @@ dword_t sys_fchownat(fd_t at_f, addr_t path_addr, dword_t owner, dword_t group,
return _EBADF;
int err;
bool follow_links = flags & AT_SYMLINK_NOFOLLOW_ ? false : true;
if (owner != -1) {
if (owner != (uid_t) -1) {
err = generic_setattrat(at, path, make_attr(uid, owner), follow_links);
if (err < 0)
return err;
}
if (group != -1) {
if (group != (uid_t) -1) {
err = generic_setattrat(at, path, make_attr(gid, group), follow_links);
if (err < 0)
return err;
Expand Down Expand Up @@ -628,7 +628,7 @@ dword_t sys_fallocate(fd_t f, dword_t UNUSED(mode), dword_t offset_low, dword_t
int err = fd->mount->fs->fstat(fd, &statbuf);
if (err < 0)
return err;
if (offset + len > statbuf.size)
if ((uint64_t) offset + (uint64_t) len > statbuf.size)
return fd->mount->fs->fsetattr(fd, make_attr(size, offset + len));
return 0;
}
Expand Down
Loading

0 comments on commit 89d5b7f

Please sign in to comment.