diff mbox series

hvf: Determine slot count from struct layout

Message ID 20211008054616.43828-1-agraf@csgraf.de (mailing list archive)
State New, archived
Headers show
Series hvf: Determine slot count from struct layout | expand

Commit Message

Alexander Graf Oct. 8, 2021, 5:46 a.m. UTC
We can handle up to a static amount of memory slots, capped by the size of
an internal array.

Let's make sure that array size is the only source of truth for the number
of elements in that array.

Signed-off-by: Alexander Graf <agraf@csgraf.de>
---
 accel/hvf/hvf-accel-ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Henderson Oct. 8, 2021, 11:48 a.m. UTC | #1
On 10/7/21 10:46 PM, Alexander Graf wrote:
> We can handle up to a static amount of memory slots, capped by the size of
> an internal array.
> 
> Let's make sure that array size is the only source of truth for the number
> of elements in that array.
> 
> Signed-off-by: Alexander Graf<agraf@csgraf.de>
> ---
>   accel/hvf/hvf-accel-ops.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Paolo Bonzini Oct. 8, 2021, 5:18 p.m. UTC | #2
On 08/10/21 07:46, Alexander Graf wrote:
> We can handle up to a static amount of memory slots, capped by the size of
> an internal array.
> 
> Let's make sure that array size is the only source of truth for the number
> of elements in that array.
> 
> Signed-off-by: Alexander Graf <agraf@csgraf.de>
> ---
>   accel/hvf/hvf-accel-ops.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
> index 6cbd2c3f97..2b2c411076 100644
> --- a/accel/hvf/hvf-accel-ops.c
> +++ b/accel/hvf/hvf-accel-ops.c
> @@ -321,7 +321,7 @@ static int hvf_accel_init(MachineState *ms)
>   
>       s = g_new0(HVFState, 1);
>   
> -    s->num_slots = 32;
> +    s->num_slots = ARRAY_SIZE(s->slots);
>       for (x = 0; x < s->num_slots; ++x) {
>           s->slots[x].size = 0;
>           s->slots[x].slot_id = x;
> 

Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 6cbd2c3f97..2b2c411076 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -321,7 +321,7 @@  static int hvf_accel_init(MachineState *ms)
 
     s = g_new0(HVFState, 1);
 
-    s->num_slots = 32;
+    s->num_slots = ARRAY_SIZE(s->slots);
     for (x = 0; x < s->num_slots; ++x) {
         s->slots[x].size = 0;
         s->slots[x].slot_id = x;