From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLKN6-0000LT-Tf for qemu-devel@nongnu.org; Mon, 18 Jan 2016 19:42:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLKN4-0003k3-Uh for qemu-devel@nongnu.org; Mon, 18 Jan 2016 19:42:08 -0500 Date: Tue, 19 Jan 2016 11:23:08 +1100 From: David Gibson Message-ID: <20160119002308.GR9301@voom.fritz.box> References: <1453091083-13931-1-git-send-email-david@gibson.dropbear.id.au> <1453091083-13931-7-git-send-email-david@gibson.dropbear.id.au> <569CAE58.4000705@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tgGnixv3tJWXBxdL" Content-Disposition: inline In-Reply-To: <569CAE58.4000705@redhat.com> Subject: Re: [Qemu-devel] [PATCHv3 6/9] pseries: Clean up error handling in spapr_rtas_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: lvivier@redhat.com, aik@ozlabs.ru, armbru@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org --tgGnixv3tJWXBxdL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 18, 2016 at 10:20:24AM +0100, Thomas Huth wrote: > On 18.01.2016 05:24, David Gibson wrote: > > The errors detected in this function necessarily indicate bugs in the r= est > > of the qemu code, rather than an external or configuration problem. > >=20 > > So, a simple assert() is more appropriate than any more complex error > > reporting. > >=20 > > Signed-off-by: David Gibson > > --- > > hw/ppc/spapr_rtas.c | 12 +++--------- > > 1 file changed, 3 insertions(+), 9 deletions(-) > >=20 > > 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, sPA= PRMachineState *spapr, > > =20 > > void spapr_rtas_register(int token, const char *name, spapr_rtas_fn fn) > > { > > - if (!((token >=3D RTAS_TOKEN_BASE) && (token < RTAS_TOKEN_MAX))) { > > - fprintf(stderr, "RTAS invalid token 0x%x\n", token); > > - exit(1); > > - } > > + assert((token >=3D RTAS_TOKEN_BASE) && (token < RTAS_TOKEN_MAX)); >=20 > While you're at it, you could also get rid of some superfluous > parentheses in that statement: >=20 > assert(token >=3D RTAS_TOKEN_BASE && token < RTAS_TOKEN_MAX); I could, but I won't because I think it's clearer as it is. > > token -=3D 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); > > - } > > + > > + assert(!rtas_table[token].name); > > =20 > > rtas_table[token].name =3D name; > > rtas_table[token].fn =3D fn; > >=20 >=20 > Anyway, patch sounds reasonable, > Reviewed-by: Thomas Huth >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --tgGnixv3tJWXBxdL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWnYHsAAoJEGw4ysog2bOSrkwP/jY4A5VM0fSv89LDK7P4d7cS nstLelP0BGnwTQZCqf3hLtYY8HwkfV0XqMTy/dLJMQouQLOtFanNvkAlAoA3YjZQ yppgJP2MfLPOgzcCgJa1/xNc2Pqze+r3x5VPXCwJjp/6T6nYXdEUQpP0Bem2uRAZ SraFEV9lFaY7qMp/TEpZdl/86oa106HLi6PV1n/01XNIHHTgUngFrnoKt47GR9cz mEcGo4u1KUn3mYqZIQ4vSCB5+7BTnuqtC41B8+JBeLl6GTM3OdjYVUOrVkDA6Dw6 aTdtavGVlW6NlaHn8W/SstdQ5Ez5w9Epht2vfEQkRtphZL3oaHdczCjANFpwCHRh 8rkhtP/UVuoXcBROzd+sJjGNfMO19qTse8nsbzfStH6nrcg0N7lVu199HDXkr7sN OCEkwlRD76kw8biiuMiQcA8TTTtsLl3Pd4oaOcoR04OLHfe84U6mzDtyiHW2dqZh 2f3JxkzREtQt3WrS6U+aqU0k4UhQgTZatodGWzeuCMgmaBWWJo85PPyTXrI8AOOS zFJ5yj4A/OdrgdGcLPwgqox0NdSCHromybYt+ZNRMG1Lr/gpf4GO0CGeZcMJVNVp r1bCjtdaVuJZH/ljFRTpNTuzLQwATIoYKVs1Bl8Jt+7Za6/Vlm/713GeUusaR+u/ FEYtg0Gg7Iw7keQTIVn8 =B+N3 -----END PGP SIGNATURE----- --tgGnixv3tJWXBxdL--