mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
src: Use 1U for bit shifting
In a few places we take 1 and shift it left repeatedly. So much that it won't longer fit into signed integer. The problem is that this is undefined behaviour. Switching to 1U makes us stay within boundaries. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
1ab5a37c4a
commit
2b20f3e0fa
@ -231,7 +231,7 @@ virDomainCapsCPUModelsGet(virDomainCapsCPUModels *cpuModels,
|
||||
const char *name);
|
||||
|
||||
#define VIR_DOMAIN_CAPS_ENUM_IS_SET(capsEnum, value) \
|
||||
((capsEnum).values & (1 << value))
|
||||
((capsEnum).values & (1U << value))
|
||||
|
||||
#define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \
|
||||
do { \
|
||||
|
@ -2575,12 +2575,12 @@ cpuidSetLeafD(virCPUData *data,
|
||||
sub1 = *cpuid;
|
||||
for (sub = 2; sub < 64; sub++) {
|
||||
if (sub < 32 &&
|
||||
!(sub0.eax & (1 << sub)) &&
|
||||
!(sub1.ecx & (1 << sub)))
|
||||
!(sub0.eax & (1U << sub)) &&
|
||||
!(sub1.ecx & (1U << sub)))
|
||||
continue;
|
||||
if (sub >= 32 &&
|
||||
!(sub0.edx & (1 << (sub - 32))) &&
|
||||
!(sub1.edx & (1 << (sub - 32))))
|
||||
!(sub0.edx & (1U << (sub - 32))) &&
|
||||
!(sub1.edx & (1U << (sub - 32))))
|
||||
continue;
|
||||
|
||||
cpuid->ecx_in = sub;
|
||||
@ -2614,7 +2614,7 @@ cpuidSetLeafResID(virCPUData *data,
|
||||
return -1;
|
||||
|
||||
for (sub = 1; sub < 32; sub++) {
|
||||
if (!(res & (1 << sub)))
|
||||
if (!(res & (1U << sub)))
|
||||
continue;
|
||||
cpuid->ecx_in = sub;
|
||||
cpuidCall(cpuid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user