From nobody Wed Oct 29 09:08:33 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 1524762625598188.97093821731812; Thu, 26 Apr 2018 10:10:25 -0700 (PDT) Received: from localhost ([::1]:43614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBkPO-0002nN-M9 for importer@patchew.org; Thu, 26 Apr 2018 13:10:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBkAC-0006jM-G3 for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:54:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBkA9-0001Sa-LE 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 1fBkA8-0001Re-Go for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:54:29 -0400 X-IronPort-AV: E=Sophos;i="5.49,330,1520899200"; d="scan'208";a="52864871" From: Ian Jackson To: Date: Thu, 26 Apr 2018 17:53:30 +0100 Message-ID: <1524761612-5307-6-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 5/7] error reporting: Provide error_report_errnoval (and error_vreport_errnoval) 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 let us replace more open coded calls to error_report and strerror. I have chosen to provide all of error_report_errno error_vreport_errno error_report_errnoval error_vreport_errnoval because the former are much more common, and deserve a short spelling; whereas there are still at least 30-40 potential callers of the latter. No callers yet so no functional change. Signed-off-by: Ian Jackson --- include/qemu/error-report.h | 5 +++++ util/qemu-error.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 2b29678..5178173 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -46,6 +46,11 @@ void error_report_errno(const char *fmt, ...) GCC_FMT_AT= TR(1, 2); void warn_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void info_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); =20 +void error_vreport_errnoval(int errnoval, + const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0= ); +void error_report_errnoval(int errnoval, + const char *fmt, ...) GCC_FMT_ATTR(2, 3); + const char *error_get_progname(void); extern bool enable_timestamp_msg; =20 diff --git a/util/qemu-error.c b/util/qemu-error.c index 428c762..8add1f3 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -257,6 +257,18 @@ void error_vreport_errno(const char *fmt, va_list ap) } =20 /* + * Print an error message to current monitor if we have one, else to stder= r. + * Format arguments like vsprintf(). The resulting message should be + * a single phrase, with no newline or trailing punctuation. + * Prepend the current location and append ": " strerror(errnoval) "\n". + * It's wrong to call this in a QMP monitor. Use error_setg() there. + */ +void error_vreport_errnoval(int errnoval, const char *fmt, va_list ap) +{ + vreport(REPORT_TYPE_ERROR, errnoval, fmt, ap); +} + +/* * Print a warning message to current monitor if we have one, else to stde= rr. * Format arguments like vsprintf(). The resulting message should be * a single phrase, with no newline or trailing punctuation. @@ -314,6 +326,22 @@ void error_report_errno(const char *fmt, ...) } =20 /* + * Print an error message to current monitor if we have one, else to stder= r. + * Format arguments like sprintf(). The resulting message should be + * a single phrase, with no newline or trailing punctuation. + * Prepend the current location and append ": " strerror(errnoval) "\n". + * It's wrong to call this in a QMP monitor. Use error_setg() there. + */ +void error_report_errnoval(int errnoval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vreport(REPORT_TYPE_ERROR, errnoval, fmt, ap); + va_end(ap); +} + +/* * Print a warning message to current monitor if we have one, else to stde= rr. * Format arguments like sprintf(). The resulting message should be a * single phrase, with no newline or trailing punctuation. --=20 2.1.4