This is an automated email from the ASF dual-hosted git repository.

cederom pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 6cb1a04fe7e53a25893d5c0aa2155e214daf230a
Author: Tiago Medicci <[email protected]>
AuthorDate: Mon Apr 20 17:15:00 2026 -0300

    system/irtest: Fix issues regarding portability and buffer size
    
    This commit fixes issues regarding portability by using variables
    with fixed width (and their format macro constants).
    
    Signed-off-by: Tiago Medicci <[email protected]>
---
 system/irtest/Kconfig |  2 +-
 system/irtest/cmd.cxx | 17 +++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/system/irtest/Kconfig b/system/irtest/Kconfig
index 34743bb87..e77bea6aa 100644
--- a/system/irtest/Kconfig
+++ b/system/irtest/Kconfig
@@ -32,7 +32,7 @@ config SYSTEM_IRTEST_MAX_NIRDEV
        default 2
 
 config SYSTEM_IRTEST_MAX_SIRDATA
-       int "The Maximum size of sending data in unsigned int"
+       int "The Maximum size of sending data in nwords (4 bytes)"
        default 64
 
 endif
diff --git a/system/irtest/cmd.cxx b/system/irtest/cmd.cxx
index d61527df7..8dde00437 100644
--- a/system/irtest/cmd.cxx
+++ b/system/irtest/cmd.cxx
@@ -226,7 +226,8 @@ CMD1(close_device, size_t, index)
 
 CMD1(write_data, size_t, index)
 {
-  unsigned int data[CONFIG_SYSTEM_IRTEST_MAX_SIRDATA];
+  uint32_t data[CONFIG_SYSTEM_IRTEST_MAX_SIRDATA];
+  uint32_t tmp;
 
   if (index >= CONFIG_SYSTEM_IRTEST_MAX_NIRDEV)
     {
@@ -236,7 +237,7 @@ CMD1(write_data, size_t, index)
   int size = 0;
   for (; size < CONFIG_SYSTEM_IRTEST_MAX_SIRDATA; size++)
     {
-      unsigned int tmp = get_next_arg < unsigned int > ();
+      tmp = get_next_arg < uint32_t > ();
       if (tmp == 0)
         {
           break;
@@ -250,14 +251,14 @@ CMD1(write_data, size_t, index)
   if (size % 2 == 0)
     {
       int result = write(g_irdevs[index], data,
-                         sizeof(unsigned int) * (size - 1));
+                         sizeof(uint32_t) * (size - 1));
       usleep(data[size - 1]);
       return result;
     }
   else
     {
       return write(g_irdevs[index], data,
-                   sizeof(unsigned int) * size);
+                   sizeof(uint32_t) * size);
     }
 }
 
@@ -268,20 +269,20 @@ CMD2(read_data, size_t, index, size_t, size)
       return ERROR;
     }
 
-  unsigned int data[size];
+  uint32_t data[size];
   int result = read(g_irdevs[index], data, sizeof(data));
   if (result > 0)
     {
-      result /= sizeof(unsigned int);
+      result /= sizeof(uint32_t);
       for (int i = 0; i < result; i++)
         {
           if (i + 1 == result)
             {
-              printf("%d\n", data[i]);
+              printf("%" PRIu32 "\n", data[i]);
             }
           else
             {
-              printf("%d, ", data[i]);
+              printf("%" PRIu32 ", ", data[i]);
             }
         }
     }

Reply via email to