From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYyxd-0004l0-4s for qemu-devel@nongnu.org; Fri, 09 Dec 2011 06:49:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYyxb-0008Uq-48 for qemu-devel@nongnu.org; Fri, 09 Dec 2011 06:49:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYyxa-0008Um-Qt for qemu-devel@nongnu.org; Fri, 09 Dec 2011 06:49:51 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB9Bnope005466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 9 Dec 2011 06:49:50 -0500 From: Amit Shah Date: Fri, 9 Dec 2011 17:19:36 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 1/3] balloon: Make functions return 0 on OK, -1 on error. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Markus Armbruster , Luiz Capitulino Current semantics of 1 on OK and 0 on error are slightly weird. qemu_balloon() and qemu_balloon_stats() do this. Other functions in the file use the standard 0 and -1 return values. This commit makes the file consistent in returning such values. Signed-off-by: Amit Shah --- balloon.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/balloon.c b/balloon.c index e1cd5fa..2b7131a 100644 --- a/balloon.c +++ b/balloon.c @@ -64,25 +64,26 @@ void qemu_remove_balloon_handler(void *opaque) static int qemu_balloon(ram_addr_t target) { if (!balloon_event_fn) { - return 0; + return -1; } trace_balloon_event(balloon_opaque, target); balloon_event_fn(balloon_opaque, target); - return 1; + return 0; } static int qemu_balloon_status(BalloonInfo *info) { if (!balloon_stat_fn) { - return 0; + return -1; } balloon_stat_fn(balloon_opaque, info); - return 1; + return 0; } BalloonInfo *qmp_query_balloon(Error **errp) { BalloonInfo *info; + int ret; if (kvm_enabled() && !kvm_has_sync_mmu()) { error_set(errp, QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); @@ -91,7 +92,8 @@ BalloonInfo *qmp_query_balloon(Error **errp) info = g_malloc0(sizeof(*info)); - if (qemu_balloon_status(info) == 0) { + ret = qemu_balloon_status(info); + if (ret < 0) { error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon"); qapi_free_BalloonInfo(info); return NULL; @@ -120,7 +122,7 @@ int do_balloon(Monitor *mon, const QDict *params, return -1; } ret = qemu_balloon(target); - if (ret == 0) { + if (ret < 0) { qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon"); return -1; } -- 1.7.7.3