[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 2/2] trace: Avoid implicit bool->integer conv
From: |
Lluís Vilanova |
Subject: |
Re: [Qemu-devel] [PATCH v3 2/2] trace: Avoid implicit bool->integer conversions |
Date: |
Thu, 11 Aug 2016 18:41:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Daniel P Berrange writes:
> On Thu, Aug 11, 2016 at 06:11:29PM +0200, Lluís Vilanova wrote:
>> An explicit if/else is clearer than arithmetic assuming #true is 1,
>> while the compiler should be able to generate just as optimal code.
>>
>> Signed-off-by: Lluís Vilanova <address@hidden>
>> ---
>> stubs/trace-control.c | 9 +++++++--
>> trace/control-target.c | 18 ++++++++++++++----
>> 2 files changed, 21 insertions(+), 6 deletions(-)
>>
>> diff --git a/stubs/trace-control.c b/stubs/trace-control.c
>> index 3740c38..099c2b5 100644
>> --- a/stubs/trace-control.c
>> +++ b/stubs/trace-control.c
>> @@ -21,8 +21,13 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool
>> state)
>> TraceEventID id;
>> assert(trace_event_get_state_static(ev));
>> id = trace_event_get_id(ev);
>> - trace_events_enabled_count += state - trace_events_dstate[id];
>> - trace_events_dstate[id] = state;
>> + if (state) {
>> + trace_events_enabled_count++;
>> + trace_events_dstate[id] = 1;
>> + } else {
>> + trace_events_enabled_count--;
> SHouldn't this be trace_events_enabled_count -= trace_events_dstate[id];
> as it is possible to call this method for a trace event that is a per-vcpu
> event
The "stub" code will never have vCPUs around, it's used by qemu-img and the like
(any program without "target" code).
I can send a v4 explicitly commenting that if you think that's necessary.
Thanks,
Lluis