From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwryF-0003Sv-PJ for qemu-devel@nongnu.org; Wed, 10 Jul 2013 06:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwryD-0001Zp-AQ for qemu-devel@nongnu.org; Wed, 10 Jul 2013 06:50:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwryD-0001ZU-2b for qemu-devel@nongnu.org; Wed, 10 Jul 2013 06:50:01 -0400 Date: Wed, 10 Jul 2013 18:49:15 +0800 From: Fam Zheng Message-ID: <20130710104915.GC18465@T430s.nay.redhat.com> References: <1373268366-14508-1-git-send-email-cngesaint@gmail.com> <1373268366-14508-2-git-send-email-cngesaint@gmail.com> <20130710102544.GA18465@T430s.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130710102544.GA18465@T430s.nay.redhat.com> Subject: Re: [Qemu-devel] [PATCH V2 1/5] Refine and export infinite loop checking in collect_image_info_list() Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xu Wang Cc: kwolf@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, xiawenc@linux.vnet.ibm.com On Wed, 07/10 18:25, Fam Zheng wrote: > > + > > + if (backing_file) { > > + /* Check if file exists. */ > > + if (access(filename, F_OK)) { > > + inode = -1; > > + } else { > > + if (stat(filename, &sbuf) == -1) { > > + error_report("Get file %s stat failed.", filename); > > + goto err; > > + } > > + inode = (long)sbuf.st_ino; > > + } > > + > > + filename = backing_file; > > + fmt = backing_format; > > + g_hash_table_insert(inodes, (gpointer)&inode, NULL); > > + } > > + > > + while (filename && (filename[0] != '\0')) { > > + if (stat(filename, &sbuf) == -1) { > Does it mean stat() on backing_file twice if it's not NULL? As you > assigned backing_file to filename above. I was wrong, the first stat() is on filename. Please ignore this noise.