From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0RqE-0008Ch-Do for qemu-devel@nongnu.org; Mon, 05 Sep 2011 01:35:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0RqD-00043w-Fj for qemu-devel@nongnu.org; Mon, 05 Sep 2011 01:35:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0RqD-00043i-7F for qemu-devel@nongnu.org; Mon, 05 Sep 2011 01:35:29 -0400 Message-ID: <4E645F9C.6060504@redhat.com> Date: Mon, 05 Sep 2011 08:35:24 +0300 From: Avi Kivity MIME-Version: 1.0 References: <4E63A548.10907@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 8/9] lsi53c895a: avoid a warning from clang analyzer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Paolo Bonzini , qemu-devel On 09/04/2011 07:27 PM, Blue Swirl wrote: > >> to be really necessary). So let's simply clear all queued > >> commands for the current device: */ > >> - id = current_tag& 0x0000ff00; > >> - QTAILQ_FOREACH_SAFE(p,&s->queue, next, p_next) { > >> - if ((p->tag& 0x0000ff00) == id) { > >> - scsi_req_cancel(p->req); > >> + { > >> + int id; > >> + > >> + id = current_tag& 0x0000ff00; > >> + QTAILQ_FOREACH_SAFE(p,&s->queue, next, p_next) { > >> + if ((p->tag& 0x0000ff00) == id) { > >> + scsi_req_cancel(p->req); > >> + } > >> } > >> } > >> > > > > Why not keep id declared in the outer scope? This extra indentation is > > annoying. > > Also the variable could be dropped altogether simply with: > if ((p->tag& 0x0000ff00) == (current_tag& 0x0000ff00)) { > > I have no preference. Yet another option is to allow intermixing declarations and statements (which C99 allows), though it tends to get some traditionalists worked up. It's particularly nice in for () loops. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.