From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7KWK-0004Lt-BM for qemu-devel@nongnu.org; Fri, 11 Dec 2015 05:01:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7KWE-00036L-Lg for qemu-devel@nongnu.org; Fri, 11 Dec 2015 05:01:48 -0500 References: <1449792685-17000-1-git-send-email-david@gibson.dropbear.id.au> <1449792685-17000-8-git-send-email-david@gibson.dropbear.id.au> From: Thomas Huth Message-ID: <566A9F01.7090203@redhat.com> Date: Fri, 11 Dec 2015 11:01:37 +0100 MIME-Version: 1.0 In-Reply-To: <1449792685-17000-8-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 07/11] pseries: Cleanup error handling in spapr_kvm_type() 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: > Use error_setg() and &error_fatal instead of an explicit exit(). >=20 > Signed-off-by: David Gibson > --- > hw/ppc/spapr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index fd16db4..546d2f5 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2035,8 +2035,8 @@ static int spapr_kvm_type(const char *vm_type) > return 2; > } > =20 > - error_report("Unknown kvm-type specified '%s'", vm_type); > - exit(1); > + error_setg(&error_fatal, "Unknown kvm-type specified '%s'", vm_typ= e); > + return 0; > } Honestly, I'd rather prefer the original code here. error_setg() should IMHO be used to set an error in an "flexible" error variable. Using it with an "hard-coded" error_fatal sounds ugly to me. And as far as I can see, no other code in QEMU uses error_setg(&error_fatal, ...) - so we should maybe not start with this in the spapr code as well. If you still would like to get rid of the exit() here ... maybe you could introduce some kind of error_report_fatal() function instead that exits after reporting the error with error_report() ? Thomas