From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSSzG-00023Z-Pq for qemu-devel@nongnu.org; Thu, 10 May 2012 09:00:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSSz6-0007lx-Gm for qemu-devel@nongnu.org; Thu, 10 May 2012 09:00:54 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:39700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSSz6-0007kb-8W for qemu-devel@nongnu.org; Thu, 10 May 2012 09:00:44 -0400 From: Peter Maydell Date: Thu, 10 May 2012 14:00:33 +0100 Message-Id: <1336654833-14698-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1336654833-14698-1-git-send-email-peter.maydell@linaro.org> References: <1336654833-14698-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 2/2] target-arm/cpu.h: Make cpu_init("nonexistent cpu") return NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org, Anthony Liguori , Paul Brook The macro definition of cpu_init meant that if cpu_arm_init() returned NULL this wouldn't result in cpu_init() itself returning NULL. This had the effect that "-cpu foo" for some unknown CPU name 'foo' would cause ARM targets to segfault rather than generating a useful error message. Fix this by making cpu_init a simple inline function. Signed-off-by: Peter Maydell Acked-by: Andreas Färber --- target-arm/cpu.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 5eac070..d01285f 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -458,7 +458,15 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum, #define TARGET_PHYS_ADDR_SPACE_BITS 32 #define TARGET_VIRT_ADDR_SPACE_BITS 32 -#define cpu_init(model) (&cpu_arm_init(model)->env) +static inline CPUARMState *cpu_init(const char *cpu_model) +{ + ARMCPU *cpu = cpu_arm_init(cpu_model); + if (cpu) { + return &cpu->env; + } + return NULL; +} + #define cpu_exec cpu_arm_exec #define cpu_gen_code cpu_arm_gen_code #define cpu_signal_handler cpu_arm_signal_handler -- 1.7.1