On 24/09/2020 18:50, Gedare Bloom wrote:

+  /* Make sure the memory allocation size computation does not overflow */
+  if ( maximum_pending_messages > SIZE_MAX / buffer_size ) {
optimization: can we use mult instead?
   if ( maximum_pending_messages * buffer_size > SIZE_MAX )
save a few cycles...
Then again, maybe the division is needed here to ensure there isn't an
overflow later? This stuff gets a little tricky!

I just used the code recommended by the SEI CERT C Coding Standard:

https://wiki.sei.cmu.edu/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to