Skip to content

Commit

Permalink
fix(core/remio): use of zero-sized array
Browse files Browse the repository at this point in the history
The specific error is triggered in the macro expansion for
OBJPOOL_ALLOC when the value CONFIG_REMIO_DEV_NUM assumes the
value of 0.
To solve this problem, we allocate only one slot if the user
does not configure any Remote I/O device.

Note: While we could use the #if macro to define the object pool
only when a Remote I/O is configured, this approach would clutter
the code with constant checks for device configuration whenever
accessing certain variables.

Signed-off-by: João Peixoto <[email protected]>
  • Loading branch information
joaopeixoto13 committed Nov 1, 2024
1 parent 3844229 commit 76104a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/remio.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ static void remio_cpu_handler(uint32_t event, uint64_t data);
CPU_MSG_HANDLER(remio_cpu_handler, REMIO_CPUMSG_ID)

/** Object pool to allocate Remote I/O devices */
OBJPOOL_ALLOC(remio_device_pool, struct remio_device, CONFIG_REMIO_DEV_NUM);
OBJPOOL_ALLOC(remio_device_pool, struct remio_device,
CONFIG_REMIO_DEV_NUM ? CONFIG_REMIO_DEV_NUM : 1);

/** Object pool to allocate pending Remote I/O requests events */
OBJPOOL_ALLOC(remio_request_event_pool, struct remio_request_event, REMIO_VCPU_NUM);
Expand Down
2 changes: 1 addition & 1 deletion src/core/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <shmem.h>
#include <objpool.h>

OBJPOOL_ALLOC(emul_cache, struct emul_mem, CONFIG_REMIO_DEV_NUM);
OBJPOOL_ALLOC(emul_cache, struct emul_mem, CONFIG_REMIO_DEV_NUM ? CONFIG_REMIO_DEV_NUM : 1);

static void vm_master_init(struct vm* vm, const struct vm_config* vm_config, vmid_t vm_id)
{
Expand Down

0 comments on commit 76104a1

Please sign in to comment.