Author: vangyzen
Date: Fri Sep 18 16:48:08 2020
New Revision: 365886
URL: https://svnweb.freebsd.org/changeset/base/365886

Log:
  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

Modified:
  head/sys/dev/fb/fbd.c
  head/sys/dev/ksyms/ksyms.c
  head/sys/dev/vt/hw/fb/vt_fb.c
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/kern/uipc_shm.c
  head/sys/kern/vfs_vnops.c
  head/sys/vm/vnode_pager.c

Modified: head/sys/dev/fb/fbd.c
==============================================================================
--- head/sys/dev/fb/fbd.c       Fri Sep 18 15:51:16 2020        (r365885)
+++ head/sys/dev/fb/fbd.c       Fri Sep 18 16:48:08 2020        (r365886)
@@ -176,7 +176,7 @@ fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_padd
        if (info->fb_flags & FB_FLAG_NOMMAP)
                return (ENODEV);
 
-       if (offset >= 0 && offset < info->fb_size) {
+       if (offset < info->fb_size) {
                if (info->fb_pbase == 0)
                        *paddr = vtophys((uint8_t *)info->fb_vbase + offset);
                else

Modified: head/sys/dev/ksyms/ksyms.c
==============================================================================
--- head/sys/dev/ksyms/ksyms.c  Fri Sep 18 15:51:16 2020        (r365885)
+++ head/sys/dev/ksyms/ksyms.c  Fri Sep 18 16:48:08 2020        (r365886)
@@ -484,7 +484,7 @@ ksyms_mmap_single(struct cdev *dev, vm_ooffset_t *offs
        if (error != 0)
                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 ||
            (nprot & ~PROT_READ) != 0)
                return (EINVAL);

Modified: head/sys/dev/vt/hw/fb/vt_fb.c
==============================================================================
--- head/sys/dev/vt/hw/fb/vt_fb.c       Fri Sep 18 15:51:16 2020        
(r365885)
+++ head/sys/dev/vt/hw/fb/vt_fb.c       Fri Sep 18 16:48:08 2020        
(r365886)
@@ -140,7 +140,7 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, 
        if (info->fb_flags & FB_FLAG_NOMMAP)
                return (ENODEV);
 
-       if (offset >= 0 && offset < info->fb_size) {
+       if (offset < info->fb_size) {
                if (info->fb_pbase == 0) {
                        *paddr = vtophys((uint8_t *)info->fb_vbase + offset);
                } else {

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_subr.c      Fri Sep 18 15:51:16 2020        
(r365885)
+++ head/sys/fs/tmpfs/tmpfs_subr.c      Fri Sep 18 16:48:08 2020        
(r365886)
@@ -178,12 +178,14 @@ RB_PROTOTYPE_STATIC(tmpfs_dir, tmpfs_dirent, uh.td_ent
 size_t
 tmpfs_mem_avail(void)
 {
-       vm_ooffset_t avail;
+       size_t avail;
+       long reserved;
 
-       avail = swap_pager_avail + vm_free_count() - tmpfs_pages_reserved;
-       if (__predict_false(avail < 0))
-               avail = 0;
-       return (avail);
+       avail = swap_pager_avail + vm_free_count();
+       reserved = atomic_load_long(&tmpfs_pages_reserved);
+       if (__predict_false(avail < reserved))
+               return (0);
+       return (avail - reserved);
 }
 
 size_t

Modified: head/sys/kern/uipc_shm.c
==============================================================================
--- head/sys/kern/uipc_shm.c    Fri Sep 18 15:51:16 2020        (r365885)
+++ head/sys/kern/uipc_shm.c    Fri Sep 18 16:48:08 2020        (r365886)
@@ -1577,7 +1577,7 @@ shm_mmap(struct file *fp, vm_map_t map, vm_offset_t *a
 #ifdef _LP64
            objsize > OFF_MAX ||
 #endif
-           foff < 0 || foff > OFF_MAX - objsize) {
+           foff > OFF_MAX - objsize) {
                error = EINVAL;
                goto out;
        }

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c   Fri Sep 18 15:51:16 2020        (r365885)
+++ head/sys/kern/vfs_vnops.c   Fri Sep 18 16:48:08 2020        (r365886)
@@ -2630,7 +2630,7 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *ad
 #ifdef _LP64
            size > OFF_MAX ||
 #endif
-           foff < 0 || foff > OFF_MAX - size)
+           foff > OFF_MAX - size)
                return (EINVAL);
 
        writecounted = FALSE;

Modified: head/sys/vm/vnode_pager.c
==============================================================================
--- head/sys/vm/vnode_pager.c   Fri Sep 18 15:51:16 2020        (r365885)
+++ head/sys/vm/vnode_pager.c   Fri Sep 18 16:48:08 2020        (r365886)
@@ -541,9 +541,6 @@ vnode_pager_addr(struct vnode *vp, vm_ooffset_t addres
        daddr_t vblock;
        daddr_t voffset;
 
-       if (address < 0)
-               return -1;
-
        if (VN_IS_DOOMED(vp))
                return -1;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to