This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push: new e86745b9a lvgldemo: use nitems instead of sizeof e86745b9a is described below commit e86745b9a2bd4c2d3b72446b908c073d6a9c9aac Author: pengyiqiang <pengyiqi...@xiaomi.com> AuthorDate: Wed Feb 22 20:57:02 2023 +0800 lvgldemo: use nitems instead of sizeof Signed-off-by: pengyiqiang <pengyiqi...@xiaomi.com> --- 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 <nuttx/config.h> #include <sys/boardctl.h> +#include <sys/param.h> #include <unistd.h> #include <stddef.h> #include <stdlib.h> @@ -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;