[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length
From: |
Vitaly Kuznetsov |
Subject: |
[PATCH v8 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length |
Date: |
Tue, 8 Jun 2021 14:08:09 +0200 |
While this is very unlikely to change, let's avoid hardcoding '12' as
'hyperv_vendor_id' length.
No functional change intended.
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
target/i386/cpu.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index a9fe1662d392..f8ae45be0d53 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6057,11 +6057,12 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu)
&error_abort);
}
len = strlen(cpu->hyperv_vendor);
- if (len > 12) {
- warn_report("hv-vendor-id truncated to 12 characters");
- len = 12;
+ if (len > sizeof(cpu->hyperv_vendor_id)) {
+ warn_report("hv-vendor-id truncated to %ld characters",
+ sizeof(cpu->hyperv_vendor_id));
+ len = sizeof(cpu->hyperv_vendor_id);
}
- memset(cpu->hyperv_vendor_id, 0, 12);
+ memset(cpu->hyperv_vendor_id, 0, sizeof(cpu->hyperv_vendor_id));
memcpy(cpu->hyperv_vendor_id, cpu->hyperv_vendor, len);
/* 'Hv#1' interface identification*/
--
2.31.1
- [PATCH v8 0/9] i386: KVM: expand Hyper-V features early, Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length,
Vitaly Kuznetsov <=
- [PATCH v8 2/9] i386: clarify 'hv-passthrough' behavior, Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 3/9] i386: hardcode supported eVMCS version to '1', Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 4/9] i386: make hyperv_expand_features() return bool, Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 5/9] i386: expand Hyper-V features during CPU feature expansion time, Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 6/9] i386: kill off hv_cpuid_check_and_set(), Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 7/9] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed, Vitaly Kuznetsov, 2021/06/08
- [PATCH v8 8/9] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS privileges, Vitaly Kuznetsov, 2021/06/08