kernel: mem_domain: fix partition end address calculations
This commit fixes the calculations of the partition ending addresses in two places in the code, according to: <last> = <start> + <size> - 1. We also rename 'end' to 'last' to stress that we calculate the last address in the partition. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
a5b7500bef
commit
3e390ed42d
1 changed files with 7 additions and 7 deletions
|
@ -19,10 +19,10 @@ static bool sane_partition(const struct k_mem_partition *part,
|
||||||
u32_t num_parts)
|
u32_t num_parts)
|
||||||
{
|
{
|
||||||
bool exec, write;
|
bool exec, write;
|
||||||
u32_t end;
|
u32_t last;
|
||||||
u32_t i;
|
u32_t i;
|
||||||
|
|
||||||
end = part->start + part->size;
|
last = part->start + part->size - 1;
|
||||||
exec = K_MEM_PARTITION_IS_EXECUTABLE(part->attr);
|
exec = K_MEM_PARTITION_IS_EXECUTABLE(part->attr);
|
||||||
write = K_MEM_PARTITION_IS_WRITABLE(part->attr);
|
write = K_MEM_PARTITION_IS_WRITABLE(part->attr);
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ static bool sane_partition(const struct k_mem_partition *part,
|
||||||
|
|
||||||
for (i = 0; i < num_parts; i++) {
|
for (i = 0; i < num_parts; i++) {
|
||||||
bool cur_write, cur_exec;
|
bool cur_write, cur_exec;
|
||||||
u32_t cur_end;
|
u32_t cur_last;
|
||||||
|
|
||||||
cur_end = parts[i].start + parts[i].size;
|
cur_last = parts[i].start + parts[i].size - 1;
|
||||||
|
|
||||||
if (end < parts[i].start || cur_end < part->start) {
|
if (last < parts[i].start || cur_last < part->start) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ static bool sane_partition(const struct k_mem_partition *part,
|
||||||
__ASSERT(false, "overlapping partitions are "
|
__ASSERT(false, "overlapping partitions are "
|
||||||
"writable and executable "
|
"writable and executable "
|
||||||
"<%x...%x>, <%x...%x>",
|
"<%x...%x>, <%x...%x>",
|
||||||
part->start, end,
|
part->start, last,
|
||||||
parts[i].start, cur_end);
|
parts[i].start, cur_last);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue