From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLgXA-0008OE-1B for qemu-devel@nongnu.org; Tue, 19 Jan 2016 19:22:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLgX5-0000zU-KP for qemu-devel@nongnu.org; Tue, 19 Jan 2016 19:21:59 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLgX5-0000zN-8m for qemu-devel@nongnu.org; Tue, 19 Jan 2016 19:21:55 -0500 Received: by mail-pf0-x244.google.com with SMTP id e65so13894257pfe.0 for ; Tue, 19 Jan 2016 16:21:54 -0800 (PST) References: <1452859244-9500-1-git-send-email-david@gibson.dropbear.id.au> <1452859244-9500-8-git-send-email-david@gibson.dropbear.id.au> <569EBFA6.6090709@redhat.com> From: Alexey Kardashevskiy Message-ID: <569ED31D.1020307@ozlabs.ru> Date: Wed, 20 Jan 2016 11:21:49 +1100 MIME-Version: 1.0 In-Reply-To: <569EBFA6.6090709@redhat.com> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/10] pseries: Clean up error handling in spapr_rtas_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , David Gibson , armbru@redhat.com Cc: qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org On 01/20/2016 09:58 AM, Eric Blake wrote: > On 01/15/2016 05:00 AM, David Gibson wrote: >> The errors detected in this function necessarily indicate bugs in the rest >> of the qemu code, rather than an external or configuration problem. >> >> So, a simple assert() is more appropriate than any more complex error >> reporting. >> >> Signed-off-by: David Gibson >> --- >> hw/ppc/spapr_rtas.c | 12 +++--------- >> 1 file changed, 3 insertions(+), 9 deletions(-) >> >> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c >> index 34b12a3..0be52ae 100644 >> --- a/hw/ppc/spapr_rtas.c >> +++ b/hw/ppc/spapr_rtas.c >> @@ -648,17 +648,11 @@ 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); >> - } >> + assert((token >= RTAS_TOKEN_BASE) && (token < RTAS_TOKEN_MAX)); > > You could drop the redundant () while touching this, as in: Seriously? Why? I personally find it really annoying (but I stay silent) when people omit braces in cases like this. > assert(token >= RTAS_TOKEN_BASE && token < RTAS_TOKEN_MAX); > -- Alexey