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

commit 2d248c1eaa4548493bd893315264498068839f40
Author: yintao <yin...@xiaomi.com>
AuthorDate: Thu Jun 20 11:01:06 2024 +0800

    examples/rpsock: fix redefined warning
    
    CC: rpsock_client.c:41:9: warning: 'ALIGN_UP' macro redefined
    
    Signed-off-by: yintao <yin...@xiaomi.com>
---
 examples/rpmsgsocket/rpsock_client.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/examples/rpmsgsocket/rpsock_client.c 
b/examples/rpmsgsocket/rpsock_client.c
index b8e36a100..335460b83 100644
--- a/examples/rpmsgsocket/rpsock_client.c
+++ b/examples/rpmsgsocket/rpsock_client.c
@@ -40,10 +40,12 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define ALIGN_UP(a)     (((a) + 0x3) & ~0x3)
-#define SYNCSIZE        CONFIG_NET_RPMSG_RXBUF_SIZE
-#define BUFSIZE         SYNCSIZE * 2
-#define BUFHEAD         64
+#define SYNCSIZE CONFIG_NET_RPMSG_RXBUF_SIZE
+#define BUFSIZE  SYNCSIZE * 2
+#define BUFHEAD  64
+#ifndef ALIGN_UP
+#  define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
+#endif
 
 /****************************************************************************
  * Private types
@@ -193,17 +195,18 @@ static int rpsock_unsync_test(FAR struct rpsock_arg_s 
*args)
 
           if (args->check && ret > 4)
             {
-              intp   = (uint32_t *)(args->inbuf + (ALIGN_UP(total) - total));
-              checks = ret - (ALIGN_UP(total) - total);
+              checks = ret - (ALIGN_UP(total, 4) - total);
+              intp   = (FAR uint32_t *)(args->inbuf +
+                                        (ALIGN_UP(total, 4) - total));
 
               for (i = 0; i < checks / sizeof(uint32_t); i++)
                 {
-                  if (intp[i] != ALIGN_UP(total) / sizeof(uint32_t) + i)
+                  if (intp[i] != ALIGN_UP(total, 4) / sizeof(uint32_t) + i)
                     {
                       printf("client check fail total %d, \
                               i %d, %08" PRIx32 ", %08zx\n",
-                              ALIGN_UP(total), i, intp[i],
-                              ALIGN_UP(total) / sizeof(uint32_t) + i);
+                              ALIGN_UP(total, 4), i, intp[i],
+                              ALIGN_UP(total, 4) / sizeof(uint32_t) + i);
                     }
                 }
             }

Reply via email to