Anthony Liguori <anth...@codemonkey.ws> writes:

> On 02/23/2011 04:46 PM, Juan Quintela wrote:
>> Anthony Liguori<anth...@codemonkey.ws>  wrote:
>>    
>>> On 02/23/2011 03:47 PM, Juan Quintela wrote:
>>>      
>>>> We are setting a pointer to a local variable in the previous line, just use
>>>> the global variable directly.  We remove the ->file test because it is 
>>>> already
>>>> done inside qemu_file_set_rate_limit() function.
>>>>
>>>>        
>>> I think this is bad form generally speaking.  Globals are not
>>> something to be embraced but rather to be isolated as much as humanly
>>> possible.
>>>      
>> current_migration is a global variable.
>>
>> And just doing:
>>
>> s = current_migration;
>>
>> foo(s);
>>
>> helps nothing.
>
> It's still bad form IMHO.  You should always use local variables to
> reference global variables unless you're explicitly setting a global
> variable.

I disagree.  The use of global variables should be made as painfully
explicit as possible.  Hiding them behind local pointers is sweeping the
globals under the rug.

For completeness: a local variable may be necessary to convince the
optimizer that the value doesn't change.  Cases where this matters
exist, but they're rare.

Reply via email to