RTEMS | cpukit/dev/flash: Fix region bitmap clear size (!1280)
mingming cheng (@kymm)
gitlab at rtems.org
Tue Jun 9 02:35:20 UTC 2026
mingming cheng commented on a discussion on cpukit/dev/flash/flashdev.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1280#note_152167
> alloc_array_len = RTEMS_FLASHDEV_BITALLOC_LENGTH( table ) +
> ( ( RTEMS_FLASHDEV_BITALLOC_FINAL_BITS( table ) ) != 0 );
>
> - memset( table->bit_allocator, 0, alloc_array_len );
> + memset( table->bit_allocator, 0, alloc_array_len * sizeof( uint32_t ) );
Thanks for the review. I've reworked the patch as suggested:
1.Renamed RTEMS_FLASHDEV_BITALLOC_LENGTH to RTEMS_FLASHDEV_BITALLOC_WORD_LENGTH. It now returns the full number of uint32_t words (rounded up), so the separate RTEMS_FLASHDEV_BITALLOC_FINAL_BITS rounding at the call site is no longer needed and has been removed.
2.Added RTEMS_FLASHDEV_BITALLOC_BYTE_LENGTH, defined as the word length times sizeof(uint32_t).
3.rtems_flashdev_register() now clears the whole bitmap with memset(table-\>bit_allocator, 0, RTEMS_FLASHDEV_BITALLOC_BYTE_LENGTH(table)) instead of the bare "\* sizeof(uint32_t)" multiplication.
Please take another look when you get a chance.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1280#note_152167
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260609/244b3cec/attachment-0001.htm>
More information about the bugs
mailing list