2016-10-13 15:46:49

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH] kvm: memset whole irq_eoi

gcc 7 warns:
arch/x86/kvm/ioapic.c: In function 'kvm_ioapic_reset':
arch/x86/kvm/ioapic.c:597:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

And it is right. Memset whole array using sizeof operator.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Radim Krčmář <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/x86/kvm/ioapic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index c7220ba94aa7..1a22de70f7f7 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -594,7 +594,7 @@ static void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
ioapic->irr = 0;
ioapic->irr_delivered = 0;
ioapic->id = 0;
- memset(ioapic->irq_eoi, 0x00, IOAPIC_NUM_PINS);
+ memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi));
rtc_irq_eoi_tracking_reset(ioapic);
}

--
2.10.1


2016-10-13 15:47:29

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH] kvm: memset whole irq_eoi

On 13/10/2016 17:45, Jiri Slaby wrote:
> gcc 7 warns:
> arch/x86/kvm/ioapic.c: In function 'kvm_ioapic_reset':
> arch/x86/kvm/ioapic.c:597:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
>
> And it is right. Memset whole array using sizeof operator.
>
> Signed-off-by: Jiri Slaby <[email protected]>
> Cc: Paolo Bonzini <[email protected]>
> Cc: Radim Krčmář <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: H. Peter Anvin <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/x86/kvm/ioapic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
> index c7220ba94aa7..1a22de70f7f7 100644
> --- a/arch/x86/kvm/ioapic.c
> +++ b/arch/x86/kvm/ioapic.c
> @@ -594,7 +594,7 @@ static void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
> ioapic->irr = 0;
> ioapic->irr_delivered = 0;
> ioapic->id = 0;
> - memset(ioapic->irq_eoi, 0x00, IOAPIC_NUM_PINS);
> + memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi));
> rtc_irq_eoi_tracking_reset(ioapic);
> }
>
>

Cc: [email protected]
Reviewed-by: Paolo Bonzini <[email protected]>

2016-10-13 16:22:03

by Radim Krčmář

[permalink] [raw]
Subject: Re: [PATCH] kvm: memset whole irq_eoi

2016-10-13 17:45+0200, Jiri Slaby:
> gcc 7 warns:
> arch/x86/kvm/ioapic.c: In function 'kvm_ioapic_reset':
> arch/x86/kvm/ioapic.c:597:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
>
> And it is right. Memset whole array using sizeof operator.
>
> Signed-off-by: Jiri Slaby <[email protected]>
> Cc: Paolo Bonzini <[email protected]>
> Cc: Radim Krčmář <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: H. Peter Anvin <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---

Added x86 subject tag and applied to kvm/queue, thanks.

> arch/x86/kvm/ioapic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
> index c7220ba94aa7..1a22de70f7f7 100644
> --- a/arch/x86/kvm/ioapic.c
> +++ b/arch/x86/kvm/ioapic.c
> @@ -594,7 +594,7 @@ static void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
> ioapic->irr = 0;
> ioapic->irr_delivered = 0;
> ioapic->id = 0;
> - memset(ioapic->irq_eoi, 0x00, IOAPIC_NUM_PINS);
> + memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi));
> rtc_irq_eoi_tracking_reset(ioapic);
> }
>
> --
> 2.10.1
>