nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-02-02 20:31:22 +08:00
committed by Xiang Xiao
parent cf0769d613
commit 3a0fdb019d
95 changed files with 291 additions and 451 deletions
+4 -4
View File
@@ -50,6 +50,8 @@
#include <errno.h>
#include <debug.h>
#include <sys/param.h>
#include <nuttx/clock.h>
#include <nuttx/kthread.h>
#include <nuttx/spinlock.h>
@@ -69,8 +71,6 @@
* Pre-processor Definitions
****************************************************************************/
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Wait up to 2.5 seconds for a response. This delay is arbitrary and
* intended only to avoid hangs while waiting for a response. It may need
* to be adjusted.
@@ -2139,7 +2139,7 @@ FAR const char *bt_addr_str(FAR const bt_addr_t *addr)
FAR char *str;
str = bufs[cur++];
cur %= ARRAY_SIZE(bufs);
cur %= nitems(bufs);
bt_addr_to_str(addr, str, sizeof(bufs[cur]));
return str;
@@ -2152,7 +2152,7 @@ FAR const char *bt_addr_le_str(FAR const bt_addr_le_t *addr)
FAR char *str;
str = bufs[cur++];
cur %= ARRAY_SIZE(bufs);
cur %= nitems(bufs);
bt_addr_le_to_str(addr, str, sizeof(bufs[cur]));
return str;
+3 -3
View File
@@ -44,6 +44,8 @@
#include <errno.h>
#include <string.h>
#include <sys/param.h>
#include <nuttx/wireless/bluetooth/bt_hci.h>
#include <nuttx/wireless/bluetooth/bt_core.h>
@@ -61,8 +63,6 @@
#define RECV_KEYS (BT_SMP_DIST_ID_KEY | BT_SMP_DIST_ENC_KEY)
#define SEND_KEYS (BT_SMP_DIST_ENC_KEY)
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/****************************************************************************
* Private Types
****************************************************************************/
@@ -326,7 +326,7 @@ static const char *h(FAR const void *buf, size_t len)
int i;
str = hexbufs[curbuf++];
curbuf %= ARRAY_SIZE(hexbufs);
curbuf %= nitems(hexbufs);
maxlen = (sizeof(hexbufs[0]) - 1) / 2;
if (len > maxlen)