From: Anthony Liguori <anthony@codemonkey.ws>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/6] monitor: Don't check for mon_get_cpu() failure
Date: Tue, 26 Jan 2010 15:34:35 -0600 [thread overview]
Message-ID: <4B5F5FEB.2060206@codemonkey.ws> (raw)
In-Reply-To: <1263989255-13755-2-git-send-email-armbru@redhat.com>
On 01/20/2010 06:07 AM, Markus Armbruster wrote:
> 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<armbru@redhat.com>
>
Applied all. Thanks.
Regards,
Anthony Liguori
> ---
> monitor.c | 39 +++------------------------------------
> 1 files changed, 3 insertions(+), 36 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 938eb3b..c22901f 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -693,8 +693,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);
> @@ -1128,7 +1126,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) {
> @@ -1190,8 +1188,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;
> @@ -1318,8 +1314,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) {
> @@ -1754,8 +1748,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");
> @@ -1812,8 +1804,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");
> @@ -2659,8 +2649,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
> @@ -2672,9 +2660,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));
> @@ -2685,40 +2670,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
> @@ -2728,8 +2703,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
> @@ -2737,8 +2710,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
> @@ -2990,7 +2961,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;
> @@ -3002,8 +2973,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:
> @@ -3090,10 +3059,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;
>
next prev parent reply other threads:[~2010-01-26 21:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-20 12:07 [Qemu-devel] [PATCH v2 0/6] Convert memsave, pmemsave, cpu to QObject+QError Markus Armbruster
2010-01-20 12:07 ` [Qemu-devel] [PATCH v2 1/6] monitor: Don't check for mon_get_cpu() failure Markus Armbruster
2010-01-26 21:34 ` Anthony Liguori [this message]
2010-01-20 12:07 ` [Qemu-devel] [PATCH v2 2/6] QError: New QERR_OPEN_FILE_FAILED Markus Armbruster
2010-01-20 12:07 ` [Qemu-devel] [PATCH v2 3/6] monitor: convert do_memory_save() to QError Markus Armbruster
2010-01-20 12:07 ` [Qemu-devel] [PATCH v2 4/6] monitor: convert do_physical_memory_save() " Markus Armbruster
2010-01-20 12:07 ` [Qemu-devel] [PATCH v2 5/6] QError: New QERR_INVALID_CPU_INDEX Markus Armbruster
2010-01-20 12:07 ` [Qemu-devel] [PATCH v2 6/6] monitor: convert do_cpu_set() to QObject, QError Markus Armbruster
2010-01-26 21:23 ` Anthony Liguori
2010-01-27 8:00 ` Markus Armbruster
2010-01-28 22:50 ` Anthony Liguori
2010-01-20 13:24 ` [Qemu-devel] [PATCH v2 0/6] Convert memsave, pmemsave, cpu to QObject+QError Luiz Capitulino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B5F5FEB.2060206@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.