From patchwork Mon Jun 22 19:26:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 487364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 395D9140077 for ; Tue, 23 Jun 2015 05:29:22 +1000 (AEST) Received: from localhost ([::1]:41766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z77PE-0006qR-4g for incoming@patchwork.ozlabs.org; Mon, 22 Jun 2015 15:29:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z77Mm-0002N9-V1 for qemu-devel@nongnu.org; Mon, 22 Jun 2015 15:26:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z77Mh-0004yB-Uq for qemu-devel@nongnu.org; Mon, 22 Jun 2015 15:26:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z77Mh-0004xv-Pp for qemu-devel@nongnu.org; Mon, 22 Jun 2015 15:26:43 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2E5832B9DC7 for ; Mon, 22 Jun 2015 19:26:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5MJQf4o003025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 22 Jun 2015 15:26:42 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id ACACF3009B5E; Mon, 22 Jun 2015 21:26:40 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 22 Jun 2015 21:26:35 +0200 Message-Id: <1435001200-20610-3-git-send-email-armbru@redhat.com> In-Reply-To: <1435001200-20610-1-git-send-email-armbru@redhat.com> References: <1435001200-20610-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, dgilbert@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 2/7] error: Make error_setg() a function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Saves a tiny amount of code at every call site. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/error.h | 4 ++-- util/error.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/qapi/error.h b/include/qapi/error.h index f44c451..34af4e1 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -51,8 +51,8 @@ void error_set_win32(Error **errp, int win32_err, ErrorClass err_class, /** * Same as error_set(), but sets a generic error */ -#define error_setg(errp, fmt, ...) \ - error_set(errp, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__) +void error_setg(Error **errp, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); #define error_setg_errno(errp, os_error, fmt, ...) \ error_set_errno(errp, os_error, ERROR_CLASS_GENERIC_ERROR, \ fmt, ## __VA_ARGS__) diff --git a/util/error.c b/util/error.c index 19982b1..7b687f6 100644 --- a/util/error.c +++ b/util/error.c @@ -56,6 +56,15 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) va_end(ap); } +void error_setg(Error **errp, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + error_setv(errp, ERROR_CLASS_GENERIC_ERROR, fmt, ap); + va_end(ap); +} + void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, const char *fmt, ...) {