From patchwork Wed Jul 28 19:30:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Di Ciurcio Filho X-Patchwork-Id: 60171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 45BA0B6EF3 for ; Thu, 29 Jul 2010 05:31:50 +1000 (EST) Received: from localhost ([127.0.0.1]:51152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeCKE-0002nO-3c for incoming@patchwork.ozlabs.org; Wed, 28 Jul 2010 15:29:58 -0400 Received: from [140.186.70.92] (port=56826 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeCJO-0002eA-WF for qemu-devel@nongnu.org; Wed, 28 Jul 2010 15:29:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OeCJ9-00044S-BK for qemu-devel@nongnu.org; Wed, 28 Jul 2010 15:28:52 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:38583) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OeCJ9-00044J-5x for qemu-devel@nongnu.org; Wed, 28 Jul 2010 15:28:51 -0400 Received: by ywt2 with SMTP id 2so1126241ywt.4 for ; Wed, 28 Jul 2010 12:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=7LeHVEE/+tG1qIeFDooq1bwniVfa7gFvrPgHAMltRo4=; b=h/2Bey2Yi4atW12sRhMZ6amPOdq7t1pGuug78M78QbqIGcWfExrhqvWxEPs0wc8MUX 39inNmlxBs2EYLriyPNHj6PJpN47buVWmjemxt9BL29auQdnzjMKDwGzdGd1Etq89caA W4+53XQKPhfCd3x7MbzL/qOAZ30CeIrLJZxJI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=MPH/PpNojJrx8VSzeXKtCBjXZ0I3W87bvcwq8BBGeoIP0KY1Y7I5EFt1w29C7RyNg5 MaYutwN0X/Y7NC36VNpq1IDT9uSJAtzOpOaILH7yUA+8qYiaID5jlANXy6k+YHO04Geq nMi2JUrjUSEPGtQz2eysb63SdvwKvQXsUDvfc= Received: by 10.151.50.14 with SMTP id c14mr7492296ybk.178.1280345328304; Wed, 28 Jul 2010 12:28:48 -0700 (PDT) Received: from localhost.localdomain (quake.ic.unicamp.br [143.106.7.51]) by mx.google.com with ESMTPS id u41sm8628909yba.10.2010.07.28.12.28.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 28 Jul 2010 12:28:45 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Wed, 28 Jul 2010 16:30:22 -0300 Message-Id: <1280345424-12918-2-git-send-email-miguel.filho@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1280345424-12918-1-git-send-email-miguel.filho@gmail.com> References: <1280345424-12918-1-git-send-email-miguel.filho@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: kwolf@redhat.com, Miguel Di Ciurcio Filho , armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 1/3] cleanup: bdrv_snaphost_find() returns zero or -ENOENT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The bdrv_snaphost_find() returns zero in case it finds an snapshot or -ENOENT in case it doesn't. Checking returning values as >= zero doesn't make sense. Signed-off-by: Miguel Di Ciurcio Filho --- savevm.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/savevm.c b/savevm.c index 7a1de3c..6c6adb0 100644 --- a/savevm.c +++ b/savevm.c @@ -1768,7 +1768,7 @@ static int del_existing_snapshots(Monitor *mon, const char *name) bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs) && - bdrv_snapshot_find(bs, snapshot, name) >= 0) + bdrv_snapshot_find(bs, snapshot, name) == 0) { ret = bdrv_snapshot_delete(bs, name); if (ret < 0) { @@ -1948,8 +1948,9 @@ int load_vmstate(const char *name) /* Don't even try to load empty VM states */ ret = bdrv_snapshot_find(bs, &sn, name); - if ((ret >= 0) && (sn.vm_state_size == 0)) - return -EINVAL; + if ((ret == 0) && (sn.vm_state_size == 0)) { + return -EINVAL; + } /* restore the VM state */ f = qemu_fopen_bdrv(bs, 0);