summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorAFWEF_147 <[email protected]>2026-03-26 13:55:23 +0000
committerRbb666 <[email protected]>2026-04-07 10:13:33 +0800
commit2960935d2e34623a316fd0e9c5f6399d9e937f04 (patch)
tree1704e6a23693f15e8ba82d7b0cb61089209afddb /libcpu
parentdedff58dd303498516a60953482991be745d0b30 (diff)
fix(libcpu): correct arm mpu region validation precedence
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/arm/cortex-m33/mpu.c4
-rw-r--r--libcpu/arm/cortex-m7/mpu.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/libcpu/arm/cortex-m33/mpu.c b/libcpu/arm/cortex-m33/mpu.c
index bddd60022c..e82084fa53 100644
--- a/libcpu/arm/cortex-m33/mpu.c
+++ b/libcpu/arm/cortex-m33/mpu.c
@@ -108,12 +108,12 @@ rt_bool_t rt_hw_mpu_region_valid(rt_mem_region_t *region)
LOG_E("Region size is too small");
return RT_FALSE;
}
- if (region->size & (~(MPU_MIN_REGION_SIZE - 1U)) != region->size)
+ if ((region->size & (~(MPU_MIN_REGION_SIZE - 1U))) != region->size)
{
LOG_E("Region size is not a multiple of 32 bytes");
return RT_FALSE;
}
- if ((rt_uint32_t)region->start & (MPU_MIN_REGION_SIZE - 1U) != 0U)
+ if (((rt_uint32_t)region->start & (MPU_MIN_REGION_SIZE - 1U)) != 0U)
{
LOG_E("Region is not aligned by 32 bytes");
return RT_FALSE;
diff --git a/libcpu/arm/cortex-m7/mpu.c b/libcpu/arm/cortex-m7/mpu.c
index 63fde3d352..e6b417da77 100644
--- a/libcpu/arm/cortex-m7/mpu.c
+++ b/libcpu/arm/cortex-m7/mpu.c
@@ -71,12 +71,12 @@ rt_bool_t rt_hw_mpu_region_valid(rt_mem_region_t *region)
LOG_E("Region size is too small");
return RT_FALSE;
}
- if (region->size & (region->size - 1U) != 0U)
+ if ((region->size & (region->size - 1U)) != 0U)
{
LOG_E("Region size is not power of 2");
return RT_FALSE;
}
- if ((rt_uint32_t)region->start & (region->size - 1U) != 0U)
+ if (((rt_uint32_t)region->start & (region->size - 1U)) != 0U)
{
LOG_E("Region is not naturally aligned");
return RT_FALSE;