diff options
author | Igor Mammedov <imammedo@redhat.com> | 2017-01-18 18:13:20 +0100 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2017-01-23 21:25:37 -0200 |
commit | 80e5db303dc82e357df923dc2bfcb858c20282a0 (patch) | |
tree | 5902487b6664ae674e4e466fbc266247b9e5f5d6 /hw/i386/pc.c | |
parent | 074281d62e62f3efab3b71161e9f0a5e8aebb0b3 (diff) | |
download | qemu-80e5db303dc82e357df923dc2bfcb858c20282a0.zip qemu-80e5db303dc82e357df923dc2bfcb858c20282a0.tar.gz qemu-80e5db303dc82e357df923dc2bfcb858c20282a0.tar.bz2 |
machine: Make possible_cpu_arch_ids() return const pointer
make sure that external callers won't try to modify
possible_cpus and owner of possible_cpus can access
it directly when it modifies it.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1484759609-264075-5-git-send-email-imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r-- | hw/i386/pc.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 079346a..c949cf0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2240,15 +2240,11 @@ static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index) return topo.pkg_id; } -static CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) +static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) { PCMachineState *pcms = PC_MACHINE(machine); - int len = sizeof(CPUArchIdList) + - sizeof(CPUArchId) * (pcms->possible_cpus->len); - CPUArchIdList *list = g_malloc(len); - - memcpy(list, pcms->possible_cpus, len); - return list; + assert(pcms->possible_cpus); + return pcms->possible_cpus; } static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machine) |