@@ -382,14 +382,14 @@ static void handle_sbi_ecall(hart_t *hart)
382382 hart -> error = ERR_NONE ;
383383}
384384
385- #define MAPPER_SIZE 4
385+ #define N_MAPPERS 4
386386
387387struct mapper {
388388 char * addr ;
389389 uint32_t size ;
390390};
391391
392- static struct mapper mapper [MAPPER_SIZE ] = {0 };
392+ static struct mapper mapper [N_MAPPERS ] = {0 };
393393static int map_index = 0 ;
394394static void unmap_files (void )
395395{
@@ -498,7 +498,7 @@ static void handle_options(int argc,
498498
499499
500500#define INIT_HART (hart , emu , id ) \
501- ({ \
501+ do { \
502502 hart->priv = emu; \
503503 hart->mhartid = id; \
504504 hart->mem_fetch = mem_fetch; \
@@ -508,7 +508,7 @@ static void handle_options(int argc,
508508 hart->s_mode = true; \
509509 hart->hsm_status = SBI_HSM_STATE_STOPPED; \
510510 vm_init(hart); \
511- })
511+ } while (0 )
512512
513513static int semu_start (int argc , char * * argv )
514514{
@@ -558,10 +558,11 @@ static int semu_start(int argc, char **argv)
558558 /* Hook for unmapping files */
559559 atexit (unmap_files );
560560
561- /* Set up RISC-V hart */
562- vm_t vm ;
563- vm .n_hart = hart_count ;
564- vm .hart = malloc (sizeof (hart_t * ) * vm .n_hart );
561+ /* Set up RISC-V harts */
562+ vm_t vm = {
563+ .n_hart = hart_count ,
564+ .hart = malloc (sizeof (hart_t * ) * vm .n_hart ),
565+ };
565566 for (uint32_t i = 0 ; i < vm .n_hart ; i ++ ) {
566567 hart_t * newhart = malloc (sizeof (hart_t ));
567568 INIT_HART (newhart , & emu , i );
0 commit comments