RTEMS | rfs: fix -Wsign-compare warnings (!892)

Joel Sherrill (@joel) gitlab at rtems.org
Thu Jan 8 15:07:55 UTC 2026




Joel Sherrill commented on a discussion on cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/892#note_138139

 >    if (rc > 0)
 >      return rc;
 >  
 > -  if (bit >= control->size)
 > +  if (bit < 0 || (size_t)bit >= control->size)

I have added comments above where I removed checks on unsigned types being < 0. It is natural to write 0 <= value <= MAX. If there is not a check in the code, it is easy to think there should be one there and you end up going down a rabbit hole. 

And yes, at least @chris and I have been on RTEMS long enough to not even remember if we wrote something specific -- much less remember some odd detail. Comments last longer and have a wider audience than memory.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/892#note_138139
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/20260108/1a5408ae/attachment.htm>


More information about the bugs mailing list