@@ -235,7 +235,7 @@ void z_riscv_init_user_accesses(struct k_thread *thread)
235235#else /* CONFIG_PMP_POWER_OF_TWO_ALIGNMENT */
236236 ulong_t rom_end = (ulong_t ) _image_rom_end ;
237237#endif /* CONFIG_PMP_POWER_OF_TWO_ALIGNMENT */
238- index = 0 ;
238+ index = 0U ;
239239 uchar_pmpcfg = (unsigned char * ) thread -> arch .u_pmpcfg ;
240240
241241#ifdef CONFIG_PMP_STACK_GUARD
@@ -277,10 +277,10 @@ void z_riscv_configure_user_allowed_stack(struct k_thread *thread)
277277
278278 z_riscv_pmp_clear_config ();
279279
280- for (i = 0 ; i < CONFIG_PMP_SLOT ; i ++ )
280+ for (i = 0U ; i < CONFIG_PMP_SLOT ; i ++ )
281281 csr_write_enum (CSR_PMPADDR0 + i , thread -> arch .u_pmpaddr [i ]);
282282
283- for (i = 0 ; i < RISCV_PMP_CFG_NUM ; i ++ )
283+ for (i = 0U ; i < RISCV_PMP_CFG_NUM ; i ++ )
284284 csr_write_enum (CSR_PMPCFG0 + i , thread -> arch .u_pmpcfg [i ]);
285285}
286286
@@ -289,7 +289,7 @@ void z_riscv_pmp_add_dynamic(struct k_thread *thread,
289289 ulong_t size ,
290290 unsigned char flags )
291291{
292- unsigned char index = 0 ;
292+ unsigned char index = 0U ;
293293 unsigned char * uchar_pmpcfg ;
294294
295295 /* Check 4 bytes alignment */
@@ -350,9 +350,9 @@ int arch_buffer_validate(void *addr, size_t size, int write)
350350 uchar_pmpcfg = (unsigned char * ) thread -> arch .u_pmpcfg ;
351351
352352#ifdef CONFIG_PMP_STACK_GUARD
353- index = 1 ;
353+ index = 1U ;
354354#else
355- index = 0 ;
355+ index = 0U ;
356356#endif /* CONFIG_PMP_STACK_GUARD */
357357
358358#if !defined(CONFIG_PMP_POWER_OF_TWO_ALIGNMENT ) || defined(CONFIG_PMP_STACK_GUARD )
@@ -378,16 +378,16 @@ __ASSERT((uchar_pmpcfg[index] & PMP_TYPE_MASK) != PMP_TOR,
378378 FROM_PMP_ADDR (thread -> arch .u_pmpaddr [index ]);
379379
380380 if ((index == CONFIG_PMP_SLOT - 1 ) ||
381- ((uchar_pmpcfg [index + 1 ] & PMP_TYPE_MASK )
381+ ((uchar_pmpcfg [index + 1U ] & PMP_TYPE_MASK )
382382 != PMP_TOR )) {
383383 pmp_addr_stop = pmp_addr_start + 4 ;
384384 } else {
385385 pmp_addr_stop = FROM_PMP_ADDR (
386- thread -> arch .u_pmpaddr [index + 1 ]);
386+ thread -> arch .u_pmpaddr [index + 1U ]);
387387 index ++ ;
388388 }
389389 } else { /* pmp_type == PMP_NAPOT */
390- for (i = 0 ; i < max_bit ; i ++ ) {
390+ for (i = 0U ; i < max_bit ; i ++ ) {
391391 if (!(thread -> arch .u_pmpaddr [index ] & (1 << i ))) {
392392 break ;
393393 }
@@ -427,19 +427,19 @@ void arch_mem_domain_partition_remove(struct k_mem_domain *domain,
427427 if (size == 4 ) {
428428 pmp_type = PMP_NA4 ;
429429 pmp_addr = TO_PMP_ADDR (start );
430- num = 1 ;
430+ num = 1U ;
431431 }
432432#if !defined(CONFIG_PMP_POWER_OF_TWO_ALIGNMENT ) || defined(CONFIG_PMP_STACK_GUARD )
433433 else if ((start & (size - 1 )) || (size & (size - 1 ))) {
434434 pmp_type = PMP_TOR ;
435435 pmp_addr = TO_PMP_ADDR (start + size );
436- num = 2 ;
436+ num = 2U ;
437437 }
438438#endif /* CONFIG_PMP_POWER_OF_TWO_ALIGNMENT || CONFIG_PMP_STACK_GUARD */
439439 else {
440440 pmp_type = PMP_NAPOT ;
441441 pmp_addr = TO_PMP_NAPOT (start , size );
442- num = 1 ;
442+ num = 1U ;
443443 }
444444
445445 node = sys_dlist_peek_head (& domain -> mem_domain_q );
@@ -478,9 +478,9 @@ void arch_mem_domain_partition_remove(struct k_mem_domain *domain,
478478 thread -> arch .u_pmpaddr [i ];
479479 }
480480
481- uchar_pmpcfg [CONFIG_PMP_SLOT - 1 ] = 0 ;
482- if (num == 2 ) {
483- uchar_pmpcfg [CONFIG_PMP_SLOT - 2 ] = 0 ;
481+ uchar_pmpcfg [CONFIG_PMP_SLOT - 1 ] = 0U ;
482+ if (num == 2U ) {
483+ uchar_pmpcfg [CONFIG_PMP_SLOT - 2 ] = 0U ;
484484 }
485485 }
486486}
@@ -528,7 +528,7 @@ void arch_mem_domain_thread_remove(struct k_thread *thread)
528528 uchar_pmpcfg = (unsigned char * ) thread -> arch .u_pmpcfg ;
529529
530530 for (i = PMP_REGION_NUM_FOR_U_THREAD ; i < CONFIG_PMP_SLOT ; i ++ ) {
531- uchar_pmpcfg [i ] = 0 ;
531+ uchar_pmpcfg [i ] = 0U ;
532532 }
533533}
534534
@@ -538,7 +538,7 @@ void arch_mem_domain_thread_remove(struct k_thread *thread)
538538
539539void z_riscv_init_stack_guard (struct k_thread * thread )
540540{
541- unsigned char index = 0 ;
541+ unsigned char index = 0U ;
542542 unsigned char * uchar_pmpcfg ;
543543 ulong_t stack_guard_addr ;
544544
@@ -594,10 +594,10 @@ void z_riscv_configure_stack_guard(struct k_thread *thread)
594594
595595 z_riscv_pmp_clear_config ();
596596
597- for (i = 0 ; i < PMP_REGION_NUM_FOR_STACK_GUARD ; i ++ )
597+ for (i = 0U ; i < PMP_REGION_NUM_FOR_STACK_GUARD ; i ++ )
598598 csr_write_enum (CSR_PMPADDR1 + i , thread -> arch .s_pmpaddr [i ]);
599599
600- for (i = 0 ; i < PMP_CFG_CSR_NUM_FOR_STACK_GUARD ; i ++ )
600+ for (i = 0U ; i < PMP_CFG_CSR_NUM_FOR_STACK_GUARD ; i ++ )
601601 csr_write_enum (CSR_PMPCFG0 + i , thread -> arch .s_pmpcfg [i ]);
602602
603603 /* Enable PMP for machine mode */
@@ -626,13 +626,13 @@ void z_riscv_pmp_init_thread(struct k_thread *thread)
626626
627627#if defined(CONFIG_PMP_STACK_GUARD )
628628 pmpcfg = thread -> arch .s_pmpcfg ;
629- for (i = 0 ; i < PMP_CFG_CSR_NUM_FOR_STACK_GUARD ; i ++ )
629+ for (i = 0U ; i < PMP_CFG_CSR_NUM_FOR_STACK_GUARD ; i ++ )
630630 pmpcfg [i ] = 0 ;
631631#endif /* CONFIG_PMP_STACK_GUARD */
632632
633633#if defined(CONFIG_USERSPACE )
634634 pmpcfg = thread -> arch .u_pmpcfg ;
635- for (i = 0 ; i < RISCV_PMP_CFG_NUM ; i ++ )
635+ for (i = 0U ; i < RISCV_PMP_CFG_NUM ; i ++ )
636636 pmpcfg [i ] = 0 ;
637637#endif /* CONFIG_USERSPACE */
638638}
0 commit comments