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 <pbonz...@redhat.com>
>> ---
>>  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