Received: from eggs.gnu.org ([208.118.235.92]:38351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuSc8-0007W2-Kz for qemu-devel@nongnu.org; Thu, 26 Jul 2012 14:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuSc7-0006Of-EZ for qemu-devel@nongnu.org; Thu, 26 Jul 2012 14:16:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuSc7-0006ON-4W for qemu-devel@nongnu.org; Thu, 26 Jul 2012 14:16:43 -0400 From: Markus Armbruster References: <1343249431-9245-1-git-send-email-lcapitulino@redhat.com> <87boj3dyxg.fsf@codemonkey.ws> <20120726161212.GL12180@redhat.com> Date: Thu, 26 Jul 2012 18:38:18 +0200 In-Reply-To: <20120726161212.GL12180@redhat.com> (Daniel P. Berrange's message of "Thu, 26 Jul 2012 17:12:12 +0100") Message-ID: <87lii6qxz9.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [RFC 00/14]: add printf-like human msg to error_set() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: peter.maydell@linaro.org, Anthony Liguori , qemu-devel@nongnu.org, Luiz Capitulino , pbonzini@redhat.com, afaerber@suse.de "Daniel P. Berrange" writes: > On Wed, Jul 25, 2012 at 09:43:55PM -0500, Anthony Liguori wrote: >> Luiz Capitulino writes: >> >> > Basically, this series changes a call like: >> > >> > error_set(errp, QERR_DEVICE_NOT_FOUND, device); >> > >> > to: >> > >> > error_set(errp, QERR_DEVICE_NOT_FOUND, >> > "Device 'device=%s' not found", device); >> > >> > In the first call, QERR_DEVICE_NOT_FOUND is a string containing a json dict: >> > >> > "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }" >> >> This is the wrong direction. Looking through the patch, this makes the >> code much more redundant overall. You have dozens of calls that are >> duplicating the same error message. This is not progress. > > What we do in libvirt, is to define helper functions for > reporting the specific error codes. So, as well as having > the generic > > error_set(errp, QERR_CODE, "format string", args) > > you would have > > error_set_device_not_found(errp, args) > > which is just a #define > > #define error_set_device_not_found(errp, args) \ > error_set(errp, QERR_DEVICE_NOT_FOUND, "Device %s not found", args) > > for the most part this should avoid the duplication you're concerned > about, while still letting use provided more detailed messsages. Yup. I suggested the same on IRC, modulo macro vs. function.