VFS: fix new signed/unsigned comparisons

This commit is contained in:
Thomas Veerman 2012-04-02 15:16:44 +00:00
parent defe329519
commit b956493367
6 changed files with 16 additions and 9 deletions

View File

@ -297,13 +297,18 @@ static void dump_segments(struct filp *f, Elf_Phdr phdrs[], int phnum)
len = phdrs[i].p_memsz; len = phdrs[i].p_memsz;
seg_off = phdrs[i].p_vaddr; seg_off = phdrs[i].p_vaddr;
for (off = 0; off < len; off += CLICK_SIZE) { if (len > LONG_MAX) {
printf("VFS: segment too large to dump, truncating\n");
len = LONG_MAX;
}
for (off = 0; off < (off_t) len; off += CLICK_SIZE) {
r = sys_vircopy(fp->fp_endpoint, D, r = sys_vircopy(fp->fp_endpoint, D,
(vir_bytes) (seg_off + off), (vir_bytes) (seg_off + off),
SELF, D, (vir_bytes) buf, SELF, D, (vir_bytes) buf,
(phys_bytes) CLICK_SIZE); (phys_bytes) CLICK_SIZE);
write_buf(f, (char *) buf, (off + CLICK_SIZE <= len) ? write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ?
CLICK_SIZE : (len - off)); CLICK_SIZE : (len - off));
} }
} }

View File

@ -523,7 +523,8 @@ int replace
* pointers are really offsets from the start of stack. * pointers are really offsets from the start of stack.
* Return true iff the operation succeeded. * Return true iff the operation succeeded.
*/ */
int offset, a0, a1; int offset;
vir_bytes a0, a1;
size_t old_bytes = *stk_bytes; size_t old_bytes = *stk_bytes;
/* Prepending arg adds at least one string and a zero byte. */ /* Prepending arg adds at least one string and a zero byte. */
@ -624,7 +625,8 @@ phys_bytes seg_bytes /* how much is to be transferred? */
assert((seg == T)||(seg == D)); assert((seg == T)||(seg == D));
/* Make sure that the file is big enough */ /* Make sure that the file is big enough */
if (vp->v_size < off+seg_bytes) return(EIO); if (off + seg_bytes > LONG_MAX) return(EIO);
if ((unsigned long) vp->v_size < off+seg_bytes) return(EIO);
if (seg == T) { if (seg == T) {
/* We have to use a copy loop until safecopies support segments */ /* We have to use a copy loop until safecopies support segments */

View File

@ -316,7 +316,7 @@ void vmnt_unmap_by_endpt(endpoint_t proc_e);
void check_vnode_locks(void); void check_vnode_locks(void);
void check_vnode_locks_by_me(struct fproc *rfp); void check_vnode_locks_by_me(struct fproc *rfp);
struct vnode *get_free_vnode(void); struct vnode *get_free_vnode(void);
struct vnode *find_vnode(int fs_e, int numb); struct vnode *find_vnode(int fs_e, ino_t inode);
void init_vnodes(void); void init_vnodes(void);
int is_vnode_locked(struct vnode *vp); int is_vnode_locked(struct vnode *vp);
int lock_vnode(struct vnode *vp, tll_access_t locktype); int lock_vnode(struct vnode *vp, tll_access_t locktype);

View File

@ -145,7 +145,7 @@ int do_select(void)
/* Verify that file descriptors are okay to select on */ /* Verify that file descriptors are okay to select on */
for (fd = 0; fd < nfds; fd++) { for (fd = 0; fd < nfds; fd++) {
struct filp *f; struct filp *f;
int type, ops; unsigned int type, ops;
/* Because the select() interface implicitly includes file descriptors /* Because the select() interface implicitly includes file descriptors
* you might not want to select on, we have to figure out whether we're * you might not want to select on, we have to figure out whether we're
@ -311,7 +311,7 @@ static int is_pipe(struct filp *f)
static int is_supported_major(struct filp *f) static int is_supported_major(struct filp *f)
{ {
/* See if this filp is a handle on a device on which we support select() */ /* See if this filp is a handle on a device on which we support select() */
int m; unsigned int m;
if (!(f && f->filp_vno)) return(FALSE); if (!(f && f->filp_vno)) return(FALSE);
if ((f->filp_vno->v_mode & I_TYPE) != I_CHAR_SPECIAL) return(FALSE); if ((f->filp_vno->v_mode & I_TYPE) != I_CHAR_SPECIAL) return(FALSE);

View File

@ -44,7 +44,7 @@ inline int copy_name( size_t len, char *dest)
if (len <= M3_STRING) { if (len <= M3_STRING) {
/* Just copy the path from the message */ /* Just copy the path from the message */
int count = 0; unsigned int count = 0;
rpu = &dest[0]; rpu = &dest[0];
rpm = job_m_in.pathname; /* contained in input message */ rpm = job_m_in.pathname; /* contained in input message */
for (count = 0; count <= len; count++) for (count = 0; count <= len; count++)

View File

@ -108,7 +108,7 @@ struct vnode *get_free_vnode()
/*===========================================================================* /*===========================================================================*
* find_vnode * * find_vnode *
*===========================================================================*/ *===========================================================================*/
struct vnode *find_vnode(int fs_e, int ino) struct vnode *find_vnode(int fs_e, ino_t ino)
{ {
/* Find a specified (FS endpoint and inode number) vnode in the /* Find a specified (FS endpoint and inode number) vnode in the
* vnode table */ * vnode table */