Skip to content

Commit 4f5460a

Browse files
Flavio Ceolinnashif
authored andcommitted
arch: arm: Fix 10.4 violations
Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category. Signed-off-by: Flavio Ceolin <[email protected]>
1 parent abb1bbe commit 4f5460a

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

arch/arm/core/aarch32/cortex_m/mpu/nxp_mpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static inline int is_in_region(uint32_t r_index, uint32_t start, uint32_t size)
455455
r_addr_start = SYSMPU->WORD[r_index][0];
456456
r_addr_end = SYSMPU->WORD[r_index][1];
457457

458-
size = size == 0 ? 0 : size - 1;
458+
size = size == 0U ? 0U : size - 1U;
459459
if (u32_add_overflow(start, size, &end)) {
460460
return 0;
461461
}

arch/arm/core/aarch32/cortex_m/timing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,5 @@ uint64_t arch_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
117117

118118
uint32_t arch_timing_freq_get_mhz(void)
119119
{
120-
return (uint32_t)(arch_timing_freq_get() / 1000000);
120+
return (uint32_t)(arch_timing_freq_get() / 1000000U);
121121
}

arch/arm64/core/mmu.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ static uint64_t *new_table(void)
3636
unsigned int i;
3737

3838
/* Look for a free table. */
39-
for (i = 0; i < CONFIG_MAX_XLAT_TABLES; i++) {
40-
if (xlat_use_count[i] == 0) {
41-
xlat_use_count[i] = 1;
39+
for (i = 0U; i < CONFIG_MAX_XLAT_TABLES; i++) {
40+
if (xlat_use_count[i] == 0U) {
41+
xlat_use_count[i] = 1U;
4242
return &xlat_tables[i * Ln_XLAT_NUM_ENTRIES];
4343
}
4444
}
@@ -61,8 +61,8 @@ static void free_table(uint64_t *table)
6161
unsigned int i = table_index(table);
6262

6363
MMU_DEBUG("freeing table [%d]%p\n", i, table);
64-
__ASSERT(xlat_use_count[i] == 1, "table still in use");
65-
xlat_use_count[i] = 0;
64+
__ASSERT(xlat_use_count[i] == 1U, "table still in use");
65+
xlat_use_count[i] = 0U;
6666
}
6767

6868
/* Adjusts usage count and returns current count. */
@@ -114,7 +114,7 @@ static inline bool is_desc_superset(uint64_t desc1, uint64_t desc2,
114114
#if DUMP_PTE
115115
static void debug_show_pte(uint64_t *pte, unsigned int level)
116116
{
117-
MMU_DEBUG("%.*s", level * 2, ". . . ");
117+
MMU_DEBUG("%.*s", level * 2U, ". . . ");
118118
MMU_DEBUG("[%d]%p: ", table_index(pte), pte);
119119

120120
if (is_free_desc(*pte)) {
@@ -194,7 +194,7 @@ static uint64_t *expand_to_table(uint64_t *pte, unsigned int level)
194194
}
195195

196196
stride_shift = LEVEL_TO_VA_SIZE_SHIFT(level + 1);
197-
for (i = 0; i < Ln_XLAT_NUM_ENTRIES; i++) {
197+
for (i = 0U; i < Ln_XLAT_NUM_ENTRIES; i++) {
198198
table[i] = desc | (i << stride_shift);
199199
}
200200
table_usage(table, Ln_XLAT_NUM_ENTRIES);
@@ -405,13 +405,13 @@ static void discard_table(uint64_t *table, unsigned int level)
405405
{
406406
unsigned int i;
407407

408-
for (i = 0; Ln_XLAT_NUM_ENTRIES; i++) {
408+
for (i = 0U; Ln_XLAT_NUM_ENTRIES; i++) {
409409
if (is_table_desc(table[i], level)) {
410410
table_usage(pte_desc_table(table[i]), -1);
411411
discard_table(pte_desc_table(table[i]), level + 1);
412412
}
413413
if (!is_free_desc(table[i])) {
414-
table[i] = 0;
414+
table[i] = 0U;
415415
table_usage(table, -1);
416416
}
417417
}
@@ -510,7 +510,7 @@ static int globalize_page_range(struct arm_mmu_ptables *dst_pt,
510510
static uint64_t get_region_desc(uint32_t attrs)
511511
{
512512
unsigned int mem_type;
513-
uint64_t desc = 0;
513+
uint64_t desc = 0U;
514514

515515
/* NS bit for security memory access from secure state */
516516
desc |= (attrs & MT_NS) ? PTE_BLOCK_DESC_NS : 0;
@@ -688,10 +688,10 @@ static void setup_page_tables(struct arm_mmu_ptables *ptables)
688688
uintptr_t max_va = 0, max_pa = 0;
689689

690690
MMU_DEBUG("xlat tables:\n");
691-
for (index = 0; index < CONFIG_MAX_XLAT_TABLES; index++)
691+
for (index = 0U; index < CONFIG_MAX_XLAT_TABLES; index++)
692692
MMU_DEBUG("%d: %p\n", index, xlat_tables + index * Ln_XLAT_NUM_ENTRIES);
693693

694-
for (index = 0; index < mmu_config.num_regions; index++) {
694+
for (index = 0U; index < mmu_config.num_regions; index++) {
695695
region = &mmu_config.mmu_regions[index];
696696
max_va = MAX(max_va, region->base_va + region->size);
697697
max_pa = MAX(max_pa, region->base_pa + region->size);
@@ -703,7 +703,7 @@ static void setup_page_tables(struct arm_mmu_ptables *ptables)
703703
"Maximum PA not supported\n");
704704

705705
/* setup translation table for zephyr execution regions */
706-
for (index = 0; index < ARRAY_SIZE(mmu_zephyr_ranges); index++) {
706+
for (index = 0U; index < ARRAY_SIZE(mmu_zephyr_ranges); index++) {
707707
range = &mmu_zephyr_ranges[index];
708708
add_arm_mmu_flat_range(ptables, range, 0);
709709
}
@@ -712,7 +712,7 @@ static void setup_page_tables(struct arm_mmu_ptables *ptables)
712712
* Create translation tables for user provided platform regions.
713713
* Those must not conflict with our default mapping.
714714
*/
715-
for (index = 0; index < mmu_config.num_regions; index++) {
715+
for (index = 0U; index < mmu_config.num_regions; index++) {
716716
region = &mmu_config.mmu_regions[index];
717717
add_arm_mmu_region(ptables, region, MT_NO_OVERWRITE);
718718
}
@@ -787,7 +787,7 @@ static sys_slist_t domain_list;
787787
*/
788788
void z_arm64_mmu_init(void)
789789
{
790-
unsigned int flags = 0;
790+
unsigned int flags = 0U;
791791

792792
__ASSERT(CONFIG_MMU_PAGE_SIZE == KB(4),
793793
"Only 4K page size is supported\n");

arch/arm64/core/prep_c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static inline void z_arm64_bss_zero(void)
3131
uint64_t *end = (uint64_t *)__bss_end;
3232

3333
while (p < end) {
34-
*p++ = 0;
34+
*p++ = 0U;
3535
}
3636
}
3737

0 commit comments

Comments
 (0)