]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
helper: types: fix proper return type in example of ARRAY_SIZE()
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 21 Jun 2025 10:11:24 +0000 (12:11 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 29 Jun 2025 07:38:46 +0000 (07:38 +0000)
The example in the comment above the declaration of the macro
ARRAY_SIZE() assigns the value to a variable of type 'unsigned'
that is not allowed by the coding style (should be 'unsigned int')
and is not correct since the macro uses 'sizeof()' and the type
returned is 'size_t'.

Fix the comment.

Change-Id: I18c32b5328a229ab74b56dafab46a064ce5d23c5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8970
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
src/helper/types.h

index 53249e5b79e407c3279df7b9334c05f06531bc86..b3edd211849c84726c2cc0f936db5b9d26187727 100644 (file)
@@ -51,7 +51,7 @@
  * Compute the number of elements of a variable length array.
  * <code>
  * const char *strs[] = { "a", "b", "c" };
- * unsigned num_strs = ARRAY_SIZE(strs);
+ * size_t num_strs = ARRAY_SIZE(strs);
  * </code>
  */
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))