From owner-svn-src-head@FreeBSD.ORG Fri Mar 20 18:30:21 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01B3F1065744; Fri, 20 Mar 2009 18:30:21 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E353F8FC22; Fri, 20 Mar 2009 18:30:20 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2KIUKS7010269; Fri, 20 Mar 2009 18:30:20 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2KIUKtr010264; Fri, 20 Mar 2009 18:30:20 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200903201830.n2KIUKtr010264@svn.freebsd.org> From: Robert Noland Date: Fri, 20 Mar 2009 18:30:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190169 - head/sys/dev/agp X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2009 18:30:21 -0000 Author: rnoland Date: Fri Mar 20 18:30:20 2009 New Revision: 190169 URL: http://svn.freebsd.org/changeset/base/190169 Log: vm_offset_t is unsigned and therefore can not be negative. Avoid unnessecary compares. Found with: Coverity Prevent(tm) CID: 2362,4215,4214,4209,4208,2363,4211,4210,4213,4212 MFC after: 3 days Modified: head/sys/dev/agp/agp.c head/sys/dev/agp/agp_amd64.c head/sys/dev/agp/agp_i810.c head/sys/dev/agp/agp_intel.c head/sys/dev/agp/agp_via.c Modified: head/sys/dev/agp/agp.c ============================================================================== --- head/sys/dev/agp/agp.c Fri Mar 20 18:29:52 2009 (r190168) +++ head/sys/dev/agp/agp.c Fri Mar 20 18:30:20 2009 (r190169) @@ -532,7 +532,7 @@ agp_generic_bind_memory(device_t dev, st int error; /* Do some sanity checks first. */ - if (offset < 0 || (offset & (AGP_PAGE_SIZE - 1)) != 0 || + if ((offset & (AGP_PAGE_SIZE - 1)) != 0 || offset + mem->am_size > AGP_GET_APERTURE(dev)) { device_printf(dev, "binding memory at bad offset %#x\n", (int)offset); Modified: head/sys/dev/agp/agp_amd64.c ============================================================================== --- head/sys/dev/agp/agp_amd64.c Fri Mar 20 18:29:52 2009 (r190168) +++ head/sys/dev/agp/agp_amd64.c Fri Mar 20 18:30:20 2009 (r190169) @@ -337,7 +337,7 @@ agp_amd64_bind_page(device_t dev, vm_off { struct agp_amd64_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = @@ -351,7 +351,7 @@ agp_amd64_unbind_page(device_t dev, vm_o { struct agp_amd64_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; Modified: head/sys/dev/agp/agp_i810.c ============================================================================== --- head/sys/dev/agp/agp_i810.c Fri Mar 20 18:29:52 2009 (r190168) +++ head/sys/dev/agp/agp_i810.c Fri Mar 20 18:30:20 2009 (r190169) @@ -840,7 +840,7 @@ agp_i810_bind_page(device_t dev, vm_offs { struct agp_i810_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) { + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) { device_printf(dev, "failed: offset is 0x%08jx, shift is %d, entries is %d\n", (intmax_t)offset, AGP_PAGE_SHIFT, sc->gatt->ag_entries); return EINVAL; } @@ -862,7 +862,7 @@ agp_i810_unbind_page(device_t dev, vm_of { struct agp_i810_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; if ( sc->chiptype != CHIP_I810 ) { @@ -1016,7 +1016,7 @@ agp_i810_bind_memory(device_t dev, struc vm_offset_t i; /* Do some sanity checks first. */ - if (offset < 0 || (offset & (AGP_PAGE_SIZE - 1)) != 0 || + if ((offset & (AGP_PAGE_SIZE - 1)) != 0 || offset + mem->am_size > AGP_GET_APERTURE(dev)) { device_printf(dev, "binding memory at bad offset %#x\n", (int)offset); Modified: head/sys/dev/agp/agp_intel.c ============================================================================== --- head/sys/dev/agp/agp_intel.c Fri Mar 20 18:29:52 2009 (r190168) +++ head/sys/dev/agp/agp_intel.c Fri Mar 20 18:30:20 2009 (r190169) @@ -371,7 +371,7 @@ agp_intel_bind_page(device_t dev, vm_off sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 0x17; @@ -385,7 +385,7 @@ agp_intel_unbind_page(device_t dev, vm_o sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return (EINVAL); sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; Modified: head/sys/dev/agp/agp_via.c ============================================================================== --- head/sys/dev/agp/agp_via.c Fri Mar 20 18:29:52 2009 (r190168) +++ head/sys/dev/agp/agp_via.c Fri Mar 20 18:30:20 2009 (r190169) @@ -362,7 +362,7 @@ agp_via_bind_page(device_t dev, vm_offse { struct agp_via_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; @@ -374,7 +374,7 @@ agp_via_unbind_page(device_t dev, vm_off { struct agp_via_softc *sc = device_get_softc(dev); - if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) + if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0;