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 2429b2ef6 ramspeed: fix -r -w parameter ignored, report align issue
2429b2ef6 is described below

commit 2429b2ef6a45097aab390cf2f5bbd63091ac3ebf
Author: buxiasen <[email protected]>
AuthorDate: Fri Aug 30 17:12:45 2024 +0800

    ramspeed: fix -r -w parameter ignored, report align issue
    
    We may want to test ramspeed by specific address, it was previous ignored,
    and for the not aligned address from user, just report a error.
    
    Signed-off-by: buxiasen <[email protected]>
---
 benchmarks/ramspeed/ramspeed_main.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/benchmarks/ramspeed/ramspeed_main.c 
b/benchmarks/ramspeed/ramspeed_main.c
index 2432f67d8..b11bdaf76 100644
--- a/benchmarks/ramspeed/ramspeed_main.c
+++ b/benchmarks/ramspeed/ramspeed_main.c
@@ -150,15 +150,26 @@ static void parse_commandline(int argc, FAR char **argv,
             break;
           case 'r':
             OPTARG_TO_VALUE(info->src, const void *, 16);
+            if (((uintptr_t)info->src & ALIGN_MASK) != 0)
+              {
+                printf(RAMSPEED_PREFIX "<read-adress> must align\n");
+                exit(EXIT_FAILURE);
+              }
+
             break;
           case 'w':
             OPTARG_TO_VALUE(info->dest, void *, 16);
+            if (((uintptr_t)info->src & ALIGN_MASK) != 0)
+              {
+                printf(RAMSPEED_PREFIX "<write-adress> must align\n");
+                exit(EXIT_FAILURE);
+              }
             break;
           case 's':
             OPTARG_TO_VALUE(info->size, size_t, 10);
             if (info->size < 32)
               {
-                printf(RAMSPEED_PREFIX "<size> must >= 32");
+                printf(RAMSPEED_PREFIX "<size> must >= 32\n");
                 exit(EXIT_FAILURE);
               }
 
@@ -187,13 +198,23 @@ static void parse_commandline(int argc, FAR char **argv,
         }
     }
 
-  if ((info->dest == NULL && !info->allocate_rw_address) || info->size == 0)
+  if (!info->allocate_rw_address && info->dest == NULL)
     {
-      printf(RAMSPEED_PREFIX "Missing required arguments\n");
+      /* We allow only set write address to test memset only.
+       * But if need test read by specific address, need write address also.
+       */
+
+      printf(RAMSPEED_PREFIX "Required Address Failed\n");
       goto out;
     }
-  else
+  else if (info->allocate_rw_address)
     {
+      if (info->size == 0)
+        {
+          printf(RAMSPEED_PREFIX "Required Size Failed\n");
+          goto out;
+        }
+
       /* We need to automatically apply for memory */
 
       printf(RAMSPEED_PREFIX "Allocate RW buffers on heap\n");

Reply via email to