hartmannathan commented on code in PR #17360:
URL: https://github.com/apache/nuttx/pull/17360#discussion_r2550500677


##########
include/sys/param.h:
##########
@@ -53,6 +53,39 @@
 #  define nitems(_a)    (sizeof(_a) / sizeof(0[(_a)]))
 #endif /* nitems */
 
+/* Macros for counting and rounding.
+ *
+ * These macros accept value to be rounded or checked as 'a' and base as 'b'.
+ * They are consistent with those provided by some BSDs.
+ *

Review Comment:
   Suggestion:
   
   ```suggestion
    * howmany() calculates how many b fit into a.
    *
    * rounddown() and roundup() round a to the next b.
    *
    * rounddown2() and roundup2() are for powers of 2 only.
    *
    * powerof2() returns 1 if a is a power of 2, 0 otherwise.
   ```
   
   Thoughts?



##########
include/sys/param.h:
##########
@@ -53,6 +53,39 @@
 #  define nitems(_a)    (sizeof(_a) / sizeof(0[(_a)]))
 #endif /* nitems */
 
+/* Macros for counting and rounding.
+ *
+ * These macros accept value to be rounded or checked as 'a' and base as 'b'.
+ * They are consistent with those provided by some BSDs.
+ *
+ * Warning: rounddown2 and roundup2 can be used only if 'b' is power of 2,
+ * otherwise they will produce wrong result.
+ */

Review Comment:
   ```suggestion
    *
    * In all of these macros, outcome is undefined if b is 0.
    *
    * All parameters are assumed to be unsigned integers.
    */
   ```



-- 
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