From nobody Wed Oct 29 09:08:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524762014447477.59631717724847; Thu, 26 Apr 2018 10:00:14 -0700 (PDT) Received: from localhost ([::1]:43540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBkFh-0003E4-KW for importer@patchew.org; Thu, 26 Apr 2018 13:00:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBkAC-0006jL-Fz for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:54:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBkA8-0001S9-1M for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:54:32 -0400 Received: from smtp03.citrix.com ([162.221.156.55]:34804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBkA7-0001Re-Ol for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:54:27 -0400 X-IronPort-AV: E=Sophos;i="5.49,330,1520899200"; d="scan'208";a="52864862" From: Ian Jackson To: Date: Thu, 26 Apr 2018 17:53:26 +0100 Message-ID: <1524761612-5307-2-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1524761612-5307-1-git-send-email-ian.jackson@eu.citrix.com> References: <1524761612-5307-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [RFC PATCH 1/7] error reporting: Introduce errnoval parameter to vreport X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This will allow new callers of vreport to specify that an errno value should be printed too. Update all existing callers. We use strerror rather than strerror_r because strerror_r presents portability difficulties. Replacing strerror with strerror_r (or something else) is left to the future. No functional change yet. Signed-off-by: Ian Jackson --- util/qemu-error.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/util/qemu-error.c b/util/qemu-error.c index a25d3b9..9acc4b5 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -191,12 +191,14 @@ bool enable_timestamp_msg; /* * Print a message to current monitor if we have one, else to stderr. * @report_type is the type of message: error, warning or informational. + * If @errnoval is nonnegative it is fed to strerror and printed too. * Format arguments like vsprintf(). The resulting message should be * a single phrase, with no newline or trailing punctuation. * Prepend the current location and append a newline. * It's wrong to call this in a QMP monitor. Use error_setg() there. */ -static void vreport(report_type type, const char *fmt, va_list ap) +static void vreport(report_type type, int errnoval, + const char *fmt, va_list ap) { GTimeVal tv; gchar *timestr; @@ -222,6 +224,11 @@ static void vreport(report_type type, const char *fmt,= va_list ap) } =20 error_vprintf(fmt, ap); + + if (errnoval >=3D 0) { + error_printf(": %s", strerror(errnoval)); + } + error_printf("\n"); } =20 @@ -234,7 +241,7 @@ static void vreport(report_type type, const char *fmt, = va_list ap) */ void error_vreport(const char *fmt, va_list ap) { - vreport(REPORT_TYPE_ERROR, fmt, ap); + vreport(REPORT_TYPE_ERROR, -1, fmt, ap); } =20 /* @@ -246,7 +253,7 @@ void error_vreport(const char *fmt, va_list ap) */ void warn_vreport(const char *fmt, va_list ap) { - vreport(REPORT_TYPE_WARNING, fmt, ap); + vreport(REPORT_TYPE_WARNING, -1, fmt, ap); } =20 /* @@ -259,7 +266,7 @@ void warn_vreport(const char *fmt, va_list ap) */ void info_vreport(const char *fmt, va_list ap) { - vreport(REPORT_TYPE_INFO, fmt, ap); + vreport(REPORT_TYPE_INFO, -1, fmt, ap); } =20 /* @@ -274,7 +281,7 @@ void error_report(const char *fmt, ...) va_list ap; =20 va_start(ap, fmt); - vreport(REPORT_TYPE_ERROR, fmt, ap); + vreport(REPORT_TYPE_ERROR, -1, fmt, ap); va_end(ap); } =20 @@ -290,7 +297,7 @@ void warn_report(const char *fmt, ...) va_list ap; =20 va_start(ap, fmt); - vreport(REPORT_TYPE_WARNING, fmt, ap); + vreport(REPORT_TYPE_WARNING, -1, fmt, ap); va_end(ap); } =20 @@ -307,6 +314,6 @@ void info_report(const char *fmt, ...) va_list ap; =20 va_start(ap, fmt); - vreport(REPORT_TYPE_INFO, fmt, ap); + vreport(REPORT_TYPE_INFO, -1, fmt, ap); va_end(ap); } --=20 2.1.4