From patchwork Fri Jan 15 16:25:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 42974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C2A74B7CC1 for ; Sat, 16 Jan 2010 03:41:00 +1100 (EST) Received: from localhost ([127.0.0.1]:34653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVpCL-0000WJ-Oz for incoming@patchwork.ozlabs.org; Fri, 15 Jan 2010 11:38:57 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVp8g-0007jp-Q5 for qemu-devel@nongnu.org; Fri, 15 Jan 2010 11:35:11 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVp8d-0007hh-7G for qemu-devel@nongnu.org; Fri, 15 Jan 2010 11:35:10 -0500 Received: from [199.232.76.173] (port=56202 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVp8c-0007hT-LR for qemu-devel@nongnu.org; Fri, 15 Jan 2010 11:35:06 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:34815) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NVp8c-00058l-3Z for qemu-devel@nongnu.org; Fri, 15 Jan 2010 11:35:06 -0500 Received: from blackfin.pond.sub.org (pD9E3B8FA.dip.t-dialin.net [217.227.184.250]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 95E07276D62 for ; Fri, 15 Jan 2010 17:25:29 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 2E10125B; Fri, 15 Jan 2010 17:25:29 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 15 Jan 2010 17:25:24 +0100 Message-Id: <1263572729-14813-2-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1263572729-14813-1-git-send-email-armbru@redhat.com> References: <1263572729-14813-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH 1/6] monitor: Don't check for mon_get_cpu() failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org mon_get_cpu() can't return null pointer, because it passes its return value to cpu_synchronize_state() first, which crashes if its argument is null. Remove the (pretty cheesy) handling of this non-existing error. Signed-off-by: Markus Armbruster --- monitor.c | 39 +++------------------------------------ 1 files changed, 3 insertions(+), 36 deletions(-) diff --git a/monitor.c b/monitor.c index b824e7c..988de73 100644 --- a/monitor.c +++ b/monitor.c @@ -682,8 +682,6 @@ static void do_info_registers(Monitor *mon) { CPUState *env; env = mon_get_cpu(); - if (!env) - return; #ifdef TARGET_I386 cpu_dump_state(env, (FILE *)mon, monitor_fprintf, X86_DUMP_FPU); @@ -1117,7 +1115,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, int flags; flags = 0; env = mon_get_cpu(); - if (!env && !is_physical) + if (!is_physical) return; #ifdef TARGET_I386 if (wsize == 2) { @@ -1179,8 +1177,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, cpu_physical_memory_rw(addr, buf, l, 0); } else { env = mon_get_cpu(); - if (!env) - break; if (cpu_memory_rw_debug(env, addr, buf, l, 0) < 0) { monitor_printf(mon, " Cannot access memory\n"); break; @@ -1307,8 +1303,6 @@ static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data) uint8_t buf[1024]; env = mon_get_cpu(); - if (!env) - return; f = fopen(filename, "wb"); if (!f) { @@ -1743,8 +1737,6 @@ static void tlb_info(Monitor *mon) uint32_t pgd, pde, pte; env = mon_get_cpu(); - if (!env) - return; if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); @@ -1801,8 +1793,6 @@ static void mem_info(Monitor *mon) uint32_t pgd, pde, pte, start, end; env = mon_get_cpu(); - if (!env) - return; if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); @@ -2648,8 +2638,6 @@ typedef struct MonitorDef { static target_long monitor_get_pc (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return env->eip + env->segs[R_CS].base; } #endif @@ -2661,9 +2649,6 @@ static target_long monitor_get_ccr (const struct MonitorDef *md, int val) unsigned int u; int i; - if (!env) - return 0; - u = 0; for (i = 0; i < 8; i++) u |= env->crf[i] << (32 - (4 * i)); @@ -2674,40 +2659,30 @@ static target_long monitor_get_ccr (const struct MonitorDef *md, int val) static target_long monitor_get_msr (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return env->msr; } static target_long monitor_get_xer (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return env->xer; } static target_long monitor_get_decr (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return cpu_ppc_load_decr(env); } static target_long monitor_get_tbu (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return cpu_ppc_load_tbu(env); } static target_long monitor_get_tbl (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return cpu_ppc_load_tbl(env); } #endif @@ -2717,8 +2692,6 @@ static target_long monitor_get_tbl (const struct MonitorDef *md, int val) static target_long monitor_get_psr (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return GET_PSR(env); } #endif @@ -2726,8 +2699,6 @@ static target_long monitor_get_psr (const struct MonitorDef *md, int val) static target_long monitor_get_reg(const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); - if (!env) - return 0; return env->regwptr[val]; } #endif @@ -2979,7 +2950,7 @@ static void expr_error(Monitor *mon, const char *msg) longjmp(expr_env, 1); } -/* return 0 if OK, -1 if not found, -2 if no CPU defined */ +/* return 0 if OK, -1 if not found */ static int get_monitor_def(target_long *pval, const char *name) { const MonitorDef *md; @@ -2991,8 +2962,6 @@ static int get_monitor_def(target_long *pval, const char *name) *pval = md->get_value(md, md->offset); } else { CPUState *env = mon_get_cpu(); - if (!env) - return -2; ptr = (uint8_t *)env + md->offset; switch(md->type) { case MD_I32: @@ -3079,10 +3048,8 @@ static int64_t expr_unary(Monitor *mon) pch++; *q = 0; ret = get_monitor_def(®, buf); - if (ret == -1) + if (ret < 0) expr_error(mon, "unknown register"); - else if (ret == -2) - expr_error(mon, "no cpu defined"); n = reg; } break;