From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJL2t-0006yS-Q7 for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:10:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJL2s-0007un-K6 for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:10:39 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:39922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJL2s-0007ua-EQ for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:10:38 -0400 Received: by mail-ey0-f173.google.com with SMTP id 6so2486272eyh.4 for ; Thu, 27 Oct 2011 01:10:37 -0700 (PDT) Date: Thu, 27 Oct 2011 08:11:11 +0100 From: Stefan Hajnoczi Message-ID: <20111027071111.GA32287@stefanha-thinkpad.localdomain> References: <1319487523-19978-1-git-send-email-sw@weilnetz.de> <20111026125431.GC27267@stefanha-thinkpad.localdomain> <4EA836BC.40409@weilnetz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4EA836BC.40409@weilnetz.de> Subject: Re: [Qemu-devel] [PATCH] Fix compiler warning (always return a value), introduce qemu_abort? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Alexander Graf , qemu-devel@nongnu.org On Wed, Oct 26, 2011 at 06:35:08PM +0200, Stefan Weil wrote: > Am 26.10.2011 14:54, schrieb Stefan Hajnoczi: > >On Mon, Oct 24, 2011 at 10:18:43PM +0200, Stefan Weil wrote: > >>For compilations with -DNDEBUG, the default case did not return > >>a value which caused a compiler warning. > >> > >>Signed-off-by: Stefan Weil > >>--- > >>hw/ppce500_spin.c | 11 ++++++++--- > >>1 files changed, 8 insertions(+), 3 deletions(-) > >> > >>diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c > >>index cccd940..5b5ffe0 100644 > >>--- a/hw/ppce500_spin.c > >>+++ b/hw/ppce500_spin.c > >>@@ -168,17 +168,22 @@ static uint64_t spin_read(void *opaque, > >>target_phys_addr_t addr, unsigned len) > >>{ > >>SpinState *s = opaque; > >>uint8_t *spin_p = &((uint8_t*)s->spin)[addr]; > >>+ uint64_t result = 0; > >> > >>switch (len) { > >>case 1: > >>- return ldub_p(spin_p); > >>+ result = ldub_p(spin_p); > >>+ break; > >>case 2: > >>- return lduw_p(spin_p); > >>+ result = lduw_p(spin_p); > >>+ break; > >>case 4: > >>- return ldl_p(spin_p); > >>+ result = ldl_p(spin_p); > >>+ break; > >>default: > >>assert(0); > > > >I would replace assert(3) with abort(3). If this ever happens the > >program is broken - returning 0 instead of an undefined value doesn't > >help. > > > >Stefan > > Alex, do you agree on replacing assert() by abort()? > > I personally don't like abort() because it does not show the > reason for the failure. > > Most users don't know how to get a core dump or how to > use gdb. And even for those who know, a crash caused > by an abort() which cannot be reproduced usually happens > on a system were ulimit disables core dumps... > > I'd like to have a qemu_abort() macro in qemu-common.h which > replaces all abort() calls used today: Sounds good. Stefan