[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' len
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH v7 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length |
Date: |
Thu, 8 Jul 2021 16:57:47 -0400 |
On Thu, Jun 03, 2021 at 01:48:27PM +0200, Vitaly Kuznetsov wrote:
> 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>
This one breaks some build due to the printf format string. See:
https://gitlab.com/ehabkost/qemu/-/jobs/1404084433
../target/i386/cpu.c: In function 'x86_cpu_hyperv_realize':
../target/i386/cpu.c:6049:50: error: format '%ld' expects argument of type
'long int', but argument 2 has type 'unsigned int' [-Werror=format=]
warn_report("hv-vendor-id truncated to %ld characters",
~~^
%d
sizeof(cpu->hyperv_vendor_id));
I'm removing it from the queue by now.
> ---
> 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
>
--
Eduardo
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v7 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length,
Eduardo Habkost <=