qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH] hvf: drop unused variable


From: Thomas Huth
Subject: Re: [Qemu-trivial] [PATCH] hvf: drop unused variable
Date: Wed, 19 Sep 2018 13:00:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 2018-09-19 12:30, Philippe Mathieu-Daudé wrote:
> On 9/18/18 11:28 AM, Paolo Bonzini wrote:
>> Signed-off-by: Paolo Bonzini <address@hidden>
>> ---
>>  target/i386/hvf/hvf.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
>> index 5db167df98..9f52bc413a 100644
>> --- a/target/i386/hvf/hvf.c
>> +++ b/target/i386/hvf/hvf.c
>> @@ -72,7 +72,6 @@
>>  #include "sysemu/sysemu.h"
>>  #include "target/i386/cpu.h"
>>  
>> -pthread_rwlock_t mem_lock = PTHREAD_RWLOCK_INITIALIZER;
>>  HVFState *hvf_state;
>>  int hvf_disabled = 1;
> 
> I'm surprised we never got a warning for this...

The variable is not marked with "static", so this is a global variable.
When compiling this file, the compiler can not know whether another file
uses "extern pthread_rwlock_t mem_lock" to access this variable, so it
can not know whether it is used or not.

To detect such unused global variables, you need to do some magic with
the linker instead. See the following URL for more information:

https://flameeyes.blog/2008/01/17/today-how-to-identify-unused-exported-functions-and-variables/

 Thomas



reply via email to

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