vm_ooffset_t is now unsigned

vm_ooffset_t is now unsigned. Remove some tests for negative values,
or make other adjustments accordingly.

Reported by:	Coverity
Reviewed by:	kib markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26214
This commit is contained in:
Eric van Gyzen 2020-09-18 16:48:08 +00:00
parent 6dadc5d1cd
commit f9cc8410e1
7 changed files with 12 additions and 13 deletions

View File

@ -176,7 +176,7 @@ fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
if (info->fb_flags & FB_FLAG_NOMMAP) if (info->fb_flags & FB_FLAG_NOMMAP)
return (ENODEV); return (ENODEV);
if (offset >= 0 && offset < info->fb_size) { if (offset < info->fb_size) {
if (info->fb_pbase == 0) if (info->fb_pbase == 0)
*paddr = vtophys((uint8_t *)info->fb_vbase + offset); *paddr = vtophys((uint8_t *)info->fb_vbase + offset);
else else

View File

@ -484,7 +484,7 @@ ksyms_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size,
if (error != 0) if (error != 0)
return (error); return (error);
if (*offset < 0 || *offset >= round_page(sc->sc_objsz) || if (*offset >= round_page(sc->sc_objsz) ||
size > round_page(sc->sc_objsz) - *offset || size > round_page(sc->sc_objsz) - *offset ||
(nprot & ~PROT_READ) != 0) (nprot & ~PROT_READ) != 0)
return (EINVAL); return (EINVAL);

View File

@ -140,7 +140,7 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr,
if (info->fb_flags & FB_FLAG_NOMMAP) if (info->fb_flags & FB_FLAG_NOMMAP)
return (ENODEV); return (ENODEV);
if (offset >= 0 && offset < info->fb_size) { if (offset < info->fb_size) {
if (info->fb_pbase == 0) { if (info->fb_pbase == 0) {
*paddr = vtophys((uint8_t *)info->fb_vbase + offset); *paddr = vtophys((uint8_t *)info->fb_vbase + offset);
} else { } else {

View File

@ -178,12 +178,14 @@ RB_PROTOTYPE_STATIC(tmpfs_dir, tmpfs_dirent, uh.td_entries, tmpfs_dirtree_cmp);
size_t size_t
tmpfs_mem_avail(void) tmpfs_mem_avail(void)
{ {
vm_ooffset_t avail; size_t avail;
long reserved;
avail = swap_pager_avail + vm_free_count() - tmpfs_pages_reserved; avail = swap_pager_avail + vm_free_count();
if (__predict_false(avail < 0)) reserved = atomic_load_long(&tmpfs_pages_reserved);
avail = 0; if (__predict_false(avail < reserved))
return (avail); return (0);
return (avail - reserved);
} }
size_t size_t

View File

@ -1577,7 +1577,7 @@ shm_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t objsize,
#ifdef _LP64 #ifdef _LP64
objsize > OFF_MAX || objsize > OFF_MAX ||
#endif #endif
foff < 0 || foff > OFF_MAX - objsize) { foff > OFF_MAX - objsize) {
error = EINVAL; error = EINVAL;
goto out; goto out;
} }

View File

@ -2630,7 +2630,7 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
#ifdef _LP64 #ifdef _LP64
size > OFF_MAX || size > OFF_MAX ||
#endif #endif
foff < 0 || foff > OFF_MAX - size) foff > OFF_MAX - size)
return (EINVAL); return (EINVAL);
writecounted = FALSE; writecounted = FALSE;

View File

@ -541,9 +541,6 @@ vnode_pager_addr(struct vnode *vp, vm_ooffset_t address, daddr_t *rtaddress,
daddr_t vblock; daddr_t vblock;
daddr_t voffset; daddr_t voffset;
if (address < 0)
return -1;
if (VN_IS_DOOMED(vp)) if (VN_IS_DOOMED(vp))
return -1; return -1;