[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length
From: |
Vitaly Kuznetsov |
Subject: |
[PATCH v7 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length |
Date: |
Thu, 3 Jun 2021 13:48:27 +0200 |
While this is very unlikely to change, let's avoid hardcoding '12' as
'hyperv_vendor_id' length.
No functional change intended.
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 fa282a07013f..b2d8e5713911 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 v7 2/9] i386: clarify 'hv-passthrough' behavior, Vitaly Kuznetsov, 2021/06/03
[PATCH v7 4/9] i386: make hyperv_expand_features() return bool, Vitaly Kuznetsov, 2021/06/03