From patchwork Wed Jul 25 20:50:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 173277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 98E232C0080 for ; Thu, 26 Jul 2012 07:08:54 +1000 (EST) Received: from localhost ([::1]:48901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su8YO-0004Yx-Km for incoming@patchwork.ozlabs.org; Wed, 25 Jul 2012 16:51:32 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su8XC-0001tW-Gk for qemu-devel@nongnu.org; Wed, 25 Jul 2012 16:50:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su8XB-0004Mo-9L for qemu-devel@nongnu.org; Wed, 25 Jul 2012 16:50:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su8XB-0004Mj-23 for qemu-devel@nongnu.org; Wed, 25 Jul 2012 16:50:17 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6PKoFja013568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jul 2012 16:50:16 -0400 Received: from localhost (ovpn-113-89.phx2.redhat.com [10.3.113.89]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6PKoEsY006497; Wed, 25 Jul 2012 16:50:15 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 25 Jul 2012 17:50:22 -0300 Message-Id: <1343249431-9245-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1343249431-9245-1-git-send-email-lcapitulino@redhat.com> References: <1343249431-9245-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, armbru@redhat.com, afaerber@suse.de, peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH 05/14] qerror: qerror_format(): return an allocated string 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 Simplifies current and future users. Signed-off-by: Luiz Capitulino --- error.c | 5 +---- qerror.c | 10 ++++++++-- qerror.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/error.c b/error.c index a52b771..b630b05 100644 --- a/error.c +++ b/error.c @@ -64,10 +64,7 @@ bool error_is_set(Error **errp) const char *error_get_pretty(Error *err) { if (err->msg == NULL) { - QString *str; - str = qerror_format(err->fmt, err->obj); - err->msg = g_strdup(qstring_get_str(str)); - QDECREF(str); + err->msg = qerror_format(err->fmt, err->obj); } return err->msg; diff --git a/qerror.c b/qerror.c index 8138186..7db28fc 100644 --- a/qerror.c +++ b/qerror.c @@ -207,9 +207,11 @@ static QString *qerror_format_desc(QDict *error, return qstring; } -QString *qerror_format(const char *fmt, QDict *error) +char *qerror_format(const char *fmt, QDict *error) { const QErrorStringTable *entry = NULL; + QString *qstr; + char *ret; int i; for (i = 0; qerror_table[i].error_fmt; i++) { @@ -219,7 +221,11 @@ QString *qerror_format(const char *fmt, QDict *error) } } - return qerror_format_desc(error, entry); + qstr = qerror_format_desc(error, entry); + ret = g_strdup(qstring_get_str(qstr)); + QDECREF(qstr); + + return ret; } /** diff --git a/qerror.h b/qerror.h index 929017c..6bf941b 100644 --- a/qerror.h +++ b/qerror.h @@ -35,6 +35,6 @@ QString *qerror_human(const QError *qerror); void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void qerror_report_err(Error *err); void assert_no_error(Error *err); -QString *qerror_format(const char *fmt, QDict *error); +char *qerror_format(const char *fmt, QDict *error); #endif /* QERROR_H */