mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
hypervisor: Revisit Coverity issues regarding cpumap
Turns out the issue regarding ptr_arith and sign_exension weren't false positives. When shifting an 'unsigned char' as a target, it gets promoted to an 'int'; however, that 'int' cannot be shifted 32 bits which was how the algorithm was written. For the ptr_arith rather than index into the cpumap, change the to address as necessary and assign directly.
This commit is contained in:
parent
cbdf3b7c97
commit
c059cdeaf3
@ -1773,17 +1773,17 @@ virXen_setvcpumap(int handle,
|
||||
ret = -1;
|
||||
} else {
|
||||
cpumap_t xen_cpumap; /* limited to 64 CPUs in old hypervisors */
|
||||
uint64_t *pm = &xen_cpumap;
|
||||
uint64_t *pm;
|
||||
int j;
|
||||
|
||||
if ((maplen > (int)sizeof(cpumap_t)) || (sizeof(cpumap_t) & 7))
|
||||
return -1;
|
||||
|
||||
memset(pm, 0, sizeof(cpumap_t));
|
||||
memset(&xen_cpumap, 0, sizeof(cpumap_t));
|
||||
for (j = 0; j < maplen; j++) {
|
||||
/* coverity[ptr_arith] */
|
||||
/* coverity[sign_extension] */
|
||||
*(pm + (j / 8)) |= cpumap[j] << (8 * (j & 7));
|
||||
if ((j & 7) == 0)
|
||||
pm = (uint64_t *)((uint64_t)&xen_cpumap + (j & ~0x7UL));
|
||||
*pm |= (uint64_t)cpumap[j] << (8 * (j & 7));
|
||||
}
|
||||
|
||||
if (hv_versions.hypervisor == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user