zephyr: lib/alloc: Relax virtual_heap_alloc() assert condition#10345
zephyr: lib/alloc: Relax virtual_heap_alloc() assert condition#10345kv2019i merged 1 commit intothesofproject:mainfrom
Conversation
Relax virtual_heap_alloc() assert condition so that it allows zero alignment for the case where no particular alignment is requested. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
There was a problem hiding this comment.
Pull Request Overview
This PR relaxes the assertion condition in the virtual_heap_alloc() function to allow zero alignment values, which represents cases where no specific alignment is requested.
- Modified the assert condition to permit zero alignment as a valid case
- Maintains existing alignment validation for non-zero alignment values
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return NULL; | ||
|
|
||
| assert(IS_ALIGNED(mem, align)); | ||
| assert(align == 0 || IS_ALIGNED(mem, align)); |
There was a problem hiding this comment.
The condition align == 0 may be misleading since zero is not a valid alignment value for memory operations. Consider checking if align is a power of 2 when non-zero, or document that zero specifically means 'no alignment requirement' to clarify the API contract.
kv2019i
left a comment
There was a problem hiding this comment.
I'll proceed as I don't think is worth the back-and-forth we already had in #10324 . If there are updated, I'd add a note about this alignment==0 zero treatmeant, as I still think this is not standard practise (e.g. C++/C compilers will give you an error if you pass a zero alignment attribute).
Relax virtual_heap_alloc() assert condition so that it allows zero alignment for the case where no particular alignment is requested.