From patchwork Fri Mar 9 18:13:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 145745 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 2B091B6FC5 for ; Sat, 10 Mar 2012 05:13:59 +1100 (EST) Received: from localhost ([::1]:37030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S64KC-0002aM-U7 for incoming@patchwork.ozlabs.org; Fri, 09 Mar 2012 13:13:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S64Jp-0001mS-A3 for qemu-devel@nongnu.org; Fri, 09 Mar 2012 13:13:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S64JV-0006N5-1S for qemu-devel@nongnu.org; Fri, 09 Mar 2012 13:13:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S64JU-0006Mg-QV for qemu-devel@nongnu.org; Fri, 09 Mar 2012 13:13:12 -0500 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 q29IDBDa020533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 9 Mar 2012 13:13:11 -0500 Received: from localhost (ovpn-113-69.phx2.redhat.com [10.3.113.69]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q29IDAs2017067; Fri, 9 Mar 2012 13:13:10 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2012 15:13:04 -0300 Message-Id: <1331316786-7752-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1331316786-7752-1-git-send-email-lcapitulino@redhat.com> References: <1331316786-7752-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, jan.kiszka@siemens.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 2/4] Error: Introduce error_copy() 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 Signed-off-by: Luiz Capitulino --- error.c | 13 +++++++++++++ error.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/error.c b/error.c index 990050f..d3455ab 100644 --- a/error.c +++ b/error.c @@ -43,6 +43,19 @@ void error_set(Error **errp, const char *fmt, ...) *errp = err; } +Error *error_copy(const Error *err) +{ + Error *err_new; + + err_new = g_malloc0(sizeof(*err)); + err_new->msg = g_strdup(err->msg); + err_new->fmt = err->fmt; + err_new->obj = err->obj; + QINCREF(err_new->obj); + + return err_new; +} + bool error_is_set(Error **errp) { return (errp && *errp); diff --git a/error.h b/error.h index 6361f40..45ff6c1 100644 --- a/error.h +++ b/error.h @@ -35,6 +35,11 @@ void error_set(Error **err, const char *fmt, ...) GCC_FMT_ATTR(2, 3); bool error_is_set(Error **err); /** + * Returns an exact copy of the error passed as an argument. + */ +Error *error_copy(const Error *err); + +/** * Get a human readable representation of an error object. */ const char *error_get_pretty(Error *err);