From patchwork Tue Dec 14 15:23:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 75498 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 07B22B6EE8 for ; Wed, 15 Dec 2010 02:25:45 +1100 (EST) Received: from localhost ([127.0.0.1]:44679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSWl3-0007XA-K0 for incoming@patchwork.ozlabs.org; Tue, 14 Dec 2010 10:25:41 -0500 Received: from [140.186.70.92] (port=33286 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSWj0-0006aO-8x for qemu-devel@nongnu.org; Tue, 14 Dec 2010 10:23:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSWiz-0004TI-57 for qemu-devel@nongnu.org; Tue, 14 Dec 2010 10:23:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSWiy-0004Ss-UE for qemu-devel@nongnu.org; Tue, 14 Dec 2010 10:23:33 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBEFNVmx025335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Dec 2010 10:23:31 -0500 Received: from blackfin.pond.sub.org (ovpn-113-44.phx2.redhat.com [10.3.113.44]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBEFNUjn010058; Tue, 14 Dec 2010 10:23:30 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 500) id EAAB52C2; Tue, 14 Dec 2010 16:23:18 +0100 (CET) From: Markus Armbruster To: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH 2/3] QMP: Drop dead code References: <1290538175-2437-1-git-send-email-lcapitulino@redhat.com> <1290538175-2437-3-git-send-email-lcapitulino@redhat.com> Date: Tue, 14 Dec 2010 16:23:18 +0100 In-Reply-To: <1290538175-2437-3-git-send-email-lcapitulino@redhat.com> (Luiz Capitulino's message of "Tue, 23 Nov 2010 16:49:34 -0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org 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 Luiz Capitulino writes: > The first if/else clause in handler_audit() makes no sense for two > reasons: > > 1. this function is now called only by QMP code, so testing if > it's a QMP call makes no sense anymore > > 2. the else clause first asserts that there's no error in the > monitor object, then it tries to free it! > > Just drop it. > > Signed-off-by: Luiz Capitulino > --- > monitor.c | 74 ++++++++++++++++++++++++++++--------------------------------- > 1 files changed, 34 insertions(+), 40 deletions(-) > > diff --git a/monitor.c b/monitor.c > index c4efe58..30be273 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -3853,49 +3853,43 @@ void monitor_set_error(Monitor *mon, QError *qerror) > > static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret) > { > - if (monitor_ctrl_mode(mon)) { > - if (ret && !monitor_has_error(mon)) { > - /* > - * If it returns failure, it must have passed on error. > - * > - * Action: Report an internal error to the client if in QMP. > - */ > - qerror_report(QERR_UNDEFINED_ERROR); > - MON_DEBUG("command '%s' returned failure but did not pass an error\n", > - cmd->name); > - } > + if (ret && !monitor_has_error(mon)) { > + /* > + * If it returns failure, it must have passed on error. > + * > + * Action: Report an internal error to the client if in QMP. > + */ > + qerror_report(QERR_UNDEFINED_ERROR); > + MON_DEBUG("command '%s' returned failure but did not pass an error\n", > + cmd->name); > + } > > #ifdef CONFIG_DEBUG_MONITOR > - if (!ret && monitor_has_error(mon)) { > - /* > - * If it returns success, it must not have passed an error. > - * > - * Action: Report the passed error to the client. > - */ > - MON_DEBUG("command '%s' returned success but passed an error\n", > - cmd->name); > - } > - > - if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) { > - /* > - * Handlers should not call Monitor print functions. > - * > - * Action: Ignore them in QMP. > - * > - * (XXX: we don't check any 'info' or 'query' command here > - * because the user print function _is_ called by do_info(), hence > - * we will trigger this check. This problem will go away when we > - * make 'query' commands real and kill do_info()) > - */ > - MON_DEBUG("command '%s' called print functions %d time(s)\n", > - cmd->name, mon_print_count_get(mon)); > - } > -#endif > - } else { > - assert(!monitor_has_error(mon)); > - QDECREF(mon->error); > - mon->error = NULL; > + if (!ret && monitor_has_error(mon)) { > + /* > + * If it returns success, it must not have passed an error. > + * > + * Action: Report the passed error to the client. > + */ > + MON_DEBUG("command '%s' returned success but passed an error\n", > + cmd->name); > + } > + > + if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) { > + /* > + * Handlers should not call Monitor print functions. > + * > + * Action: Ignore them in QMP. > + * > + * (XXX: we don't check any 'info' or 'query' command here > + * because the user print function _is_ called by do_info(), hence > + * we will trigger this check. This problem will go away when we > + * make 'query' commands real and kill do_info()) > + */ > + MON_DEBUG("command '%s' called print functions %d time(s)\n", > + cmd->name, mon_print_count_get(mon)); > } > +#endif > } > > static void handle_user_command(Monitor *mon, const char *cmdline) For easier review: $ git-diff -w diff --git a/monitor.c b/monitor.c index 8cee35d..138db06 100644 --- a/monitor.c +++ b/monitor.c @@ -3853,7 +3853,6 @@ void monitor_set_error(Monitor *mon, QError *qerror) static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret) { - if (monitor_ctrl_mode(mon)) { if (ret && !monitor_has_error(mon)) { /* * If it returns failure, it must have passed on error. @@ -3891,11 +3890,6 @@ static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret) cmd->name, mon_print_count_get(mon)); } #endif - } else { - assert(!monitor_has_error(mon)); - QDECREF(mon->error); - mon->error = NULL; - } } static void handle_user_command(Monitor *mon, const char *cmdline)