qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 16/28] migration: use global variable directly


From: Juan Quintela
Subject: [Qemu-devel] Re: [PATCH 16/28] migration: use global variable directly
Date: Thu, 24 Feb 2011 00:07:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Anthony Liguori <address@hidden> wrote:
> On 02/23/2011 04:46 PM, Juan Quintela wrote:
>> Anthony Liguori<address@hidden>  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.

Obviounly tastes change between us :-(

If I want to do that, instead of creating a local variable, I will just
add a parameter to the function and make the callers to pass it.

For me, a variable in a function is global or local, hidden it as a
local has no merit.

Later, Juan.



reply via email to

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