From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Skeggs Subject: Re: smatch: nouveau: bogus compare against zero Date: Tue, 21 Dec 2010 11:12:12 +1000 Message-ID: <1292893935.2214.13.camel@nisroch> References: <20101220064825.GP1936@bicker> Reply-To: bskeggs@redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id 50F439E7A4 for ; Mon, 20 Dec 2010 17:12:40 -0800 (PST) In-Reply-To: <20101220064825.GP1936@bicker> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Dan Carpenter Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Mon, 2010-12-20 at 09:48 +0300, Dan Carpenter wrote: > Hi Ben, > > This is a new Smatch warning in linux-next. It comes from: a11c3198c > "drm/nv50: import new vm code" Thanks, fix queued in my tree. Will get to Dave eventually :) Ben. > > drivers/gpu/drm/nouveau/nv50_vm.c +104 nv50_vm_map(13) > warn: bogus compare against zero: 'i' > > 94 u32 block, i; > 95 > 96 phys = nv50_vm_addr(vma, pgt, phys, mem->memtype, 0); > 97 pte <<= 3; > 98 cnt <<= 3; > 99 > 100 while (cnt) { > 101 u32 offset_h = upper_32_bits(phys); > 102 u32 offset_l = lower_32_bits(phys); > 103 > 104 for (i = 7; i >= 0; i--) { > ^^^^^^ > > i is unsigned so this test is always true. > > 105 block = 1 << (i + 3); > 106 if (cnt >= block && !(pte & (block - 1))) > 107 break; > 108 } > 109 offset_l |= (i << 7); > > regards, > dan carpenter