From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOTHx-0001Uy-9T for qemu-devel@nongnu.org; Wed, 17 Oct 2012 09:04:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOTHs-0007fR-Nr for qemu-devel@nongnu.org; Wed, 17 Oct 2012 09:03:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOTHs-0007fN-G9 for qemu-devel@nongnu.org; Wed, 17 Oct 2012 09:03:52 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9HD3o3t014935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Oct 2012 09:03:51 -0400 Message-ID: <507EACB0.7040608@redhat.com> Date: Wed, 17 Oct 2012 15:03:44 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1349275025-5093-1-git-send-email-pbonzini@redhat.com> <1349275025-5093-2-git-send-email-pbonzini@redhat.com> <8762698dfs.fsf@blackfin.pond.sub.org> In-Reply-To: <8762698dfs.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 01/18] error: add error_set_errno and error_setg_errno List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com Il 17/10/2012 14:56, Markus Armbruster ha scritto: > Duplicates error_set() code without need. How about: > > void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, > const char *fmt, ...) > { > char *msg; > > va_start(ap, fmt); > msg = g_strdup_printf(fmt, ap); > va_end(ap); > if (os_errno) { > error_set(errp, err_class, "%s: %s", msg, strerror(os_errno)); > } else { > error_set(errp, err_class, "%s", msg); > } > g_free(msg); > } > > Sketch, not even compile-tested. > > Or the other way round, implement error_set() in terms of the more > general error_set_errno(): > > void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) > { > error_set(errp, err_class, 0, fmt, ...); > } > > Except that's not C; real code needs verror_set_errno(). > > As usual, every variadic function sooner or later needs a buddy that > takes a va_list instead. Indeed... lazy me. Added to my todo list. Paolo