Received: from eggs.gnu.org ([209.51.188.92]:54434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0S-00055a-8B for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0R-0005A0-3P for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0Q-00059H-SI for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B67FC81DFE for ; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) From: Markus Armbruster Date: Thu, 18 Apr 2019 22:51:02 +0200 Message-Id: <20190418205135.6686-4-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> Subject: [Qemu-devel] [PULL for-4.1 03/36] error: Fix error_report_err(), warn_report_err() hint printing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Before the from qerror_report() to error_setg(), hints looked like this: qerror_report(QERR_MACRO, ... arguments ...); error_printf_unless_qmp(... hint ...); error_printf_unless_qmp() made perfect sense: it printed exactly when qerror_report() did. After the conversion to error_setg(): error_setg(errp, QERR_MACRO, ... arguments ...); error_printf_unless_qmp(... hint ...); The "unless QMP part" still made some sense; in QMP context, the caller generally uses the error as QMP response instead of printing it. However, everything else is wrong. If the caller handles the error, the hint gets printed anyway (unless QMP). If the caller reports the error, the hint gets printed *before* the report (unless QMP) or not at all (if QMP). Commit 50b7b000c91 fixed this by making hints a member of Error. It kept printing hints with error_printf_unless_qmp(): void error_report_err(Error *err) { error_report("%s", error_get_pretty(err)); + if (err->hint) { + error_printf_unless_qmp("%s\n", err->hint->str); + } error_free(err); } This is wrong. We should (and now can) print the hint exactly when we print the error. The mistake has since been copied to warn_report_err() in commit e43ead1d0b9. Fix both to use error_printf(). Reported-by: Vladimir Sementsov-Ogievskiy Cc: Eric Blake Signed-off-by: Markus Armbruster Message-Id: <20190416153850.5186-1-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy [Commit message tweaked] --- util/error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/error.c b/util/error.c index 934a78e1b1..712b4d4b5d 100644 --- a/util/error.c +++ b/util/error.c @@ -223,7 +223,7 @@ void error_report_err(Error *err) { error_report("%s", error_get_pretty(err)); if (err->hint) { - error_printf_unless_qmp("%s", err->hint->str); + error_printf("%s", err->hint->str); } error_free(err); } @@ -232,7 +232,7 @@ void warn_report_err(Error *err) { warn_report("%s", error_get_pretty(err)); if (err->hint) { - error_printf_unless_qmp("%s", err->hint->str); + error_printf("%s", err->hint->str); } error_free(err); } -- 2.17.2