From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7Kai-0006wR-SF for qemu-devel@nongnu.org; Fri, 11 Dec 2015 05:06:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7Kae-0004Hi-8r for qemu-devel@nongnu.org; Fri, 11 Dec 2015 05:06:20 -0500 References: <1449792685-17000-1-git-send-email-david@gibson.dropbear.id.au> <1449792685-17000-9-git-send-email-david@gibson.dropbear.id.au> From: Thomas Huth Message-ID: <566AA014.30903@redhat.com> Date: Fri, 11 Dec 2015 11:06:12 +0100 MIME-Version: 1.0 In-Reply-To: <1449792685-17000-9-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 08/11] pseries: Clean up error handling in spapr_rtas_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , armbru@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com Cc: lvivier@redhat.com, qemu-ppc@nongnu.org, agraf@suse.de, qemu-devel@nongnu.org On 11/12/15 01:11, David Gibson wrote: > The errors detected in this function indicate problems with the rest of > the machine type code, rather than configuration or runtime problems. > > Use error_setg() and &error_abort instead of explicit fprintf() and exit(). > > Signed-off-by: David Gibson > --- > hw/ppc/spapr_rtas.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > index 34b12a3..db4a675 100644 > --- a/hw/ppc/spapr_rtas.c > +++ b/hw/ppc/spapr_rtas.c > @@ -649,15 +649,14 @@ target_ulong spapr_rtas_call(PowerPCCPU *cpu, sPAPRMachineState *spapr, > void spapr_rtas_register(int token, const char *name, spapr_rtas_fn fn) > { > if (!((token >= RTAS_TOKEN_BASE) && (token < RTAS_TOKEN_MAX))) { > - fprintf(stderr, "RTAS invalid token 0x%x\n", token); > - exit(1); > + error_setg(&error_abort, "RTAS invalid token 0x%x", token); > } > > token -= RTAS_TOKEN_BASE; > if (rtas_table[token].name) { > - fprintf(stderr, "RTAS call \"%s\" is registered already as 0x%x\n", > - rtas_table[token].name, token); > - exit(1); > + error_setg(&error_abort, > + "RTAS call \"%s\" is registered already as 0x%x", > + rtas_table[token].name, token); > } As with the last patch, I also think these error_setg(&error_abort, ...) are rather ugly. Maybe use error_report() + abort() instead? Thomas