Received: from eggs.gnu.org ([2001:4830:134:3::10]:55676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9r6i-0005Fg-4C for qemu-devel@nongnu.org; Fri, 18 Dec 2015 04:13:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9r6e-0002Lr-Qj for qemu-devel@nongnu.org; Fri, 18 Dec 2015 04:13:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9r6e-0002Ln-Lq for qemu-devel@nongnu.org; Fri, 18 Dec 2015 04:13:44 -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 (Postfix) with ESMTPS id 66D9B1A65DD for ; Fri, 18 Dec 2015 09:13:44 +0000 (UTC) From: Markus Armbruster References: <1450371004-26866-1-git-send-email-armbru@redhat.com> <1450371004-26866-10-git-send-email-armbru@redhat.com> <567319C3.8090105@redhat.com> Date: Fri, 18 Dec 2015 10:13:41 +0100 In-Reply-To: <567319C3.8090105@redhat.com> (Eric Blake's message of "Thu, 17 Dec 2015 13:23:31 -0700") Message-ID: <877fkcjf0a.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 09/23] error: New error_prepend(), error_reportf_err() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org Eric Blake writes: > On 12/17/2015 09:49 AM, Markus Armbruster wrote: >> Instead of simply propagating an error verbatim, we sometimes want to >> add to its message, like this: >> >> frobnicate(arg, &err); >> error_setg(errp, "Can't frobnicate %s: %s", >> arg, error_get_pretty(err)); > > Did you intend to have literal TABs in the commit message? Editing accident, fixed. >> error_free(err); >> >> This is suboptimal, because it loses err's hint (if any). Moreover, >> when errp is &error_abort or is subsequently propagated to >> &error_abort, the abort message points to the place where we last >> added to the error, not to the place where it originated. >> >> To avoid these issues, provide means to add to an error's message in >> place: >> >> frobnicate(arg, errp); >> error_prepend(errp, "Can't frobnicate %s: ", arg); >> >> Likewise, reporting an error like >> >> frobnicate(arg, &err); >> error_report("Can't frobnicate %s: %s", arg, error_get_pretty(err)); >> >> can lose err's hint. To avoid: >> >> error_reportf_err(err, "Can't frobnicate %s: ", arg); >> >> The next commits will put these functions to use. >> >> Signed-off-by: Markus Armbruster >> --- >> include/qapi/error.h | 31 +++++++++++++++++++++++++++++-- >> util/error.c | 33 +++++++++++++++++++++++++++++++++ >> 2 files changed, 62 insertions(+), 2 deletions(-) >> > > Reviewed-by: Eric Blake Thanks!