qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 04/16] pc: forbid BSP removal


From: Bandan Das
Subject: Re: [Qemu-devel] [PATCH v4 04/16] pc: forbid BSP removal
Date: Thu, 14 Jul 2016 17:02:40 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eduardo Habkost <address@hidden> writes:
...
>> >>                                       DeviceState *dev, Error **errp)
>> >>  {
>> >> +    int idx;
>> >>      HotplugHandlerClass *hhc;
>> >>      Error *local_err = NULL;
>> >>      PCMachineState *pcms = PC_MACHINE(hotplug_dev);
>> >>  
>> >> +    pc_find_cpu_slot(pcms, CPU(dev), &idx);
>> >
>> > Looks fragile: if one day we create any TYPE_CPU object that is
>> > not in possible_cpus array, idx is undefined. I suggest
>> > initializing idx to -1 above.
>> 
>> Or just let pc_find_cpu_slot universally set it to -1 since
>> this series assumes that -1 means index isn't valid.
>
> I think it would be more intuitive if pc_find_cpu_slot() didn't
> touch *idx if no slot is found. But both ways sound good to me.

The caller then has to always take care of making sure there
is no bogus value in idx. Maybe, always calling if (pc_find_cpu_slot())
is better.



reply via email to

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