[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Re: [PATCH 16/28] migration: use global variable direct
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] Re: [PATCH 16/28] migration: use global variable directly |
Date: |
Thu, 24 Feb 2011 08:09:50 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Anthony Liguori <address@hidden> writes:
> 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.
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.
- [Qemu-devel] [PATCH 13/28] migration: Remove get_status() accessor, (continued)
- [Qemu-devel] [PATCH 13/28] migration: Remove get_status() accessor, Juan Quintela, 2011/02/23
- [Qemu-devel] [PATCH 14/28] migration: Remove migration cancel() callback, Juan Quintela, 2011/02/23
- [Qemu-devel] [PATCH 08/28] migration: Check that migration is active before cancel it, Juan Quintela, 2011/02/23
- [Qemu-devel] [PATCH 06/28] migration: Make all posible migration functions static, Juan Quintela, 2011/02/23
- [Qemu-devel] [PATCH 03/28] migration: Fold MigrationState into FdMigrationState, Juan Quintela, 2011/02/23
- [Qemu-devel] [PATCH 16/28] migration: use global variable directly, Juan Quintela, 2011/02/23
[Qemu-devel] [PATCH 17/28] migration: another case of global variable assigned to local one, Juan Quintela, 2011/02/23
[Qemu-devel] [PATCH 18/28] migration: convert current_migration from pointer to struct, Juan Quintela, 2011/02/23
[Qemu-devel] [PATCH 19/28] migration: Use bandwidth_limit directly, Juan Quintela, 2011/02/23
[Qemu-devel] [PATCH 07/28] migration: move migrate_create_state to do_migrate, Juan Quintela, 2011/02/23
[Qemu-devel] [PATCH 20/28] migration: Export a function that tells if the migration has finished correctly, Juan Quintela, 2011/02/23
[Qemu-devel] [PATCH 21/28] migration: Make state definitions local, Juan Quintela, 2011/02/23