From e86745b9a2bd4c2d3b72446b908c073d6a9c9aac Mon Sep 17 00:00:00 2001 From: pengyiqiang Date: Wed, 22 Feb 2023 20:57:02 +0800 Subject: [PATCH] lvgldemo: use nitems instead of sizeof Signed-off-by: pengyiqiang --- examples/lvgldemo/lvgldemo.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/lvgldemo/lvgldemo.c b/examples/lvgldemo/lvgldemo.c index 8bc986cde..3b32c0e9e 100644 --- a/examples/lvgldemo/lvgldemo.c +++ b/examples/lvgldemo/lvgldemo.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -113,8 +114,7 @@ static const struct func_key_pair_s func_key_pair[] = static void show_usage(void) { int i; - const int len = sizeof(func_key_pair) - / sizeof(struct func_key_pair_s) - 1; + const int len = nitems(func_key_pair) - 1; if (len == 0) { @@ -141,8 +141,7 @@ static void show_usage(void) static demo_create_func_t find_demo_create_func(FAR const char *name) { int i; - const int len = sizeof(func_key_pair) - / sizeof(struct func_key_pair_s) - 1; + const int len = nitems(func_key_pair) - 1; for (i = 0; i < len; i++) { @@ -177,8 +176,7 @@ int main(int argc, FAR char *argv[]) { demo_create_func_t demo_create_func; FAR const char *demo = NULL; - const int func_key_pair_len = sizeof(func_key_pair) / - sizeof(func_key_pair[0]); + const int func_key_pair_len = nitems(func_key_pair); #ifdef CONFIG_LIBUV uv_loop_t ui_loop;