xiaoxiang781216 commented on code in PR #14559:
URL: https://github.com/apache/nuttx/pull/14559#discussion_r1822567915


##########
libs/libc/obstack/lib_obstack_make_room.c:
##########
@@ -69,12 +71,14 @@ void obstack_make_room(FAR struct obstack *h, size_t size)
 
   size += object_size + sizeof(struct _obstack_chunk);
 
-  /* Note: this is rounding up to the multiple of chunk size that is power of
-   * two. Thus this creates limitation that chunks can be only power of two.
+  /* Note: this is rounding up to the multiple of chunk size that is rounded
+   * up to the power of two.
    */
 
-  mask = h->chunk_size;
-  for (i = 1; i < sizeof(size_t); i <<= 1)
+  DEBUGASSERT(h->chunk_size > 0);
+
+  mask = h->chunk_size - 1;
+  for (i = 1; i < sizeof(size_t) * 8; i <<= 1)
       mask |= mask >> i;

Review Comment:
   add {}



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to