From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTFaJ-0007kB-Ao for qemu-devel@nongnu.org; Tue, 21 Jul 2009 09:40:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTFaE-0007i9-Ec for qemu-devel@nongnu.org; Tue, 21 Jul 2009 09:40:46 -0400 Received: from [199.232.76.173] (port=59670 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTFaE-0007i2-7j for qemu-devel@nongnu.org; Tue, 21 Jul 2009 09:40:42 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:57801) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MTFaD-0003A6-U5 for qemu-devel@nongnu.org; Tue, 21 Jul 2009 09:40:42 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e9.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n6LDdsHk024136 for ; Tue, 21 Jul 2009 09:39:54 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n6LDebUm242174 for ; Tue, 21 Jul 2009 09:40:37 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n6LDebwp012248 for ; Tue, 21 Jul 2009 09:40:37 -0400 Message-ID: <4A65C554.3020708@us.ibm.com> Date: Tue, 21 Jul 2009 08:40:36 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1248183933-20986-1-git-send-email-glommer@redhat.com> In-Reply-To: <1248183933-20986-1-git-send-email-glommer@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] fix ioctl return value List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: qemu-devel@nongnu.org Glauber Costa wrote: > we expect a number less than 0, not exactly -1. > And furthermore, we return errno itself, so no need to use it. > > This might break guests when this ioctl fails for some reason. > > Signed-off-by: Glauber Costa > --- > kvm-all.c | 5 ++--- > 1 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/kvm-all.c b/kvm-all.c > index 8567ac9..9a79466 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -319,9 +319,8 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, > > d.slot = mem->slot; > > - if (kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) == -1) { > - dprintf("ioctl failed %d\n", errno); > - ret = -1; > + if ((ret = kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d)) < 0) { > + dprintf("ioctl failed %d\n", ret); > While this is fine, I usually prefer: ret = kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d); if (ret < 0) { dprintf(ioctl failed %d\n", ret); -- Regards, Anthony Liguori