qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Avoid segfault in cpu_dump_state


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH] Avoid segfault in cpu_dump_state
Date: Wed, 16 May 2012 05:50:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0

Am 15.05.2012 18:08, schrieb Fabien Chouteau:
> On 05/15/2012 03:31 PM, Andreas Färber wrote:
>> Am 15.05.2012 11:39, schrieb Fabien Chouteau:
>>> Do not call cpu_dump_state if logfile is NULL.
>>
>> And where is log_cpu_state() being called from? Its caller is passing
>> NULL already then.
>>
> 
> No, logfile is a global variable. log_cpu_state() takes only CPUState
> and flags parameters.

Ah, I see now that f is a different f here, logfile becomes
log_cpu_state()'s f. Unfortunate naming.

Your fix looks OK then but I would recommend turning it into a static
inline function to avoid the line breaks.

Andreas

>>> Signed-off-by: Fabien Chouteau <address@hidden>
>>> ---
>>>  qemu-log.h |    7 ++++++-
>>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/qemu-log.h b/qemu-log.h
>>> index fccfb110..2cd5ffa 100644
>>> --- a/qemu-log.h
>>> +++ b/qemu-log.h
>>> @@ -51,7 +51,12 @@ extern int loglevel;
>>>  /* Special cases: */
>>>  
>>>  /* cpu_dump_state() logging functions: */
>>> -#define log_cpu_state(env, f) cpu_dump_state((env), logfile, fprintf, (f));
>>> +#define log_cpu_state(env, f)                          \
>>> +do {                                                   \
>>> +    if (logfile != NULL) {                             \
>>> +        cpu_dump_state((env), logfile, fprintf, (f));  \
>>> +    }                                                  \
>>> + } while (0)
>>>  #define log_cpu_state_mask(b, env, f) do {           \
>>>        if (loglevel & (b)) log_cpu_state((env), (f)); \
>>>    } while (0)

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]