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

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


The following commit(s) were added to refs/heads/master by this push:
     new d364d7a  system: Fix nx[looper|player|recorder] warning
d364d7a is described below

commit d364d7a8109c7a9d3964cf3e9287ecf5a5a6dbd6
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue Mar 22 02:09:07 2022 +0800

    system: Fix nx[looper|player|recorder] warning
    
    nxlooper.c:879:7: warning: 'strncpy' specified bound 96 equals destination 
size [-Wstringop-truncation]
      879 |       strncpy(plooper->recorddev, pdevice, 
sizeof(plooper->playdev));
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nxlooper.c:875:7: warning: 'strncpy' specified bound 96 equals destination 
size [-Wstringop-truncation]
      875 |       strncpy(plooper->playdev, pdevice, sizeof(plooper->playdev));
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nxlooper.c: In function 'nxlooper_loopraw':
    nxlooper.c:165:52: warning: '%s' directive output may be truncated writing 
up to 96 bytes into a region of size 53 [-Wformat-truncation=]
      165 |           snprintf(path, sizeof(path), "/dev/audio/%s", 
pdevice->d_name);
          |                                                    ^~
    nxlooper.c:165:11: note: 'snprintf' output between 12 and 108 bytes into a 
destination of size 64
      165 |           snprintf(path, sizeof(path), "/dev/audio/%s", 
pdevice->d_name);
          |           
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nxplayer.c: In function 'nxplayer_playinternal':
    nxplayer.c:359:53: warning: '%s' directive output may be truncated writing 
up to 96 bytes into a region of size 53 [-Wformat-truncation=]
      359 |           snprintf(path,  sizeof(path), "/dev/audio/%s", 
pdevice->d_name);
          |                                                     ^~
    nxplayer.c:359:11: note: 'snprintf' output between 12 and 108 bytes into a 
destination of size 64
      359 |           snprintf(path,  sizeof(path), "/dev/audio/%s", 
pdevice->d_name);
          |           
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nxrecorder.c: In function 'nxrecorder_setdevice':
    nxrecorder.c:695:3: warning: 'strncpy' specified bound 96 equals 
destination size [-Wstringop-truncation]
      695 |   strncpy(precorder->device, pdevice, sizeof(precorder->device));
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nxplayer.c: In function 'nxplayer_setdevice':
    nxplayer.c:1686:3: warning: 'strncpy' specified bound 96 equals destination 
size [-Wstringop-truncation]
     1686 |   strncpy(pplayer->prefdevice, pdevice, 
sizeof(pplayer->prefdevice));
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CC:  nxrecorder_main.c
    nxplayer.c: In function 'nxplayer_setmediadir':
    nxplayer.c:2090:3: warning: 'strncpy' specified bound 96 equals destination 
size [-Wstringop-truncation]
     2090 |   strncpy(pplayer->mediadir, mediadir, sizeof(pplayer->mediadir));
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 system/nxlooper/nxlooper.c          |  8 ++++----
 system/nxlooper/nxlooper_main.c     |  2 +-
 system/nxplayer/nxplayer.c          |  6 +++---
 system/nxplayer/nxplayer_main.c     | 11 +++++++----
 system/nxrecorder/nxrecorder.c      |  2 +-
 system/nxrecorder/nxrecorder_main.c |  4 ++--
 6 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/system/nxlooper/nxlooper.c b/system/nxlooper/nxlooper.c
index a3fa219..74b78d6 100644
--- a/system/nxlooper/nxlooper.c
+++ b/system/nxlooper/nxlooper.c
@@ -121,7 +121,7 @@ static int nxlooper_opendevice(FAR struct nxlooper_s 
*plooper)
       struct audio_caps_s caps;
       FAR struct dirent *pdevice;
       FAR DIR *dirp;
-      char path[64];
+      char path[PATH_MAX];
 
       /* Search for a device in the audio device directory */
 
@@ -851,11 +851,11 @@ int nxlooper_setdevice(FAR struct nxlooper_s *plooper,
 
   if (caps.ac_controls.b[0] & AUDIO_TYPE_OUTPUT)
     {
-      strncpy(plooper->playdev, pdevice, sizeof(plooper->playdev));
+      strlcpy(plooper->playdev, pdevice, sizeof(plooper->playdev));
     }
   else if (caps.ac_controls.b[0] & AUDIO_TYPE_INPUT)
     {
-      strncpy(plooper->recorddev, pdevice, sizeof(plooper->playdev));
+      strlcpy(plooper->recorddev, pdevice, sizeof(plooper->recorddev));
     }
 
   return OK;
@@ -1297,7 +1297,7 @@ int nxlooper_systemreset(FAR struct nxlooper_s *plooper)
   struct audio_caps_s caps;
   FAR struct dirent   *pdevice;
   FAR DIR             *dirp;
-  char                path[64];
+  char                path[PATH_MAX];
   int                 temp_fd;
 
   /* Search for a device in the audio device directory */
diff --git a/system/nxlooper/nxlooper_main.c b/system/nxlooper/nxlooper_main.c
index 8941497..7650b94 100644
--- a/system/nxlooper/nxlooper_main.c
+++ b/system/nxlooper/nxlooper_main.c
@@ -348,7 +348,7 @@ static int nxlooper_cmd_resume(FAR struct nxlooper_s 
*plooper, char *parg)
 static int nxlooper_cmd_device(FAR struct nxlooper_s *plooper, char *parg)
 {
   int  ret;
-  char path[32];
+  char path[PATH_MAX];
 
   /* First try to open the file directly */
 
diff --git a/system/nxplayer/nxplayer.c b/system/nxplayer/nxplayer.c
index a4e0c8e..614a713 100644
--- a/system/nxplayer/nxplayer.c
+++ b/system/nxplayer/nxplayer.c
@@ -1683,7 +1683,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pplayer,
 
   /* Save the path and format capabilities of the preferred device */
 
-  strncpy(pplayer->prefdevice, pdevice, sizeof(pplayer->prefdevice));
+  strlcpy(pplayer->prefdevice, pdevice, sizeof(pplayer->prefdevice));
   pplayer->prefformat = caps.ac_format.b[0] | (caps.ac_format.b[1] << 8);
   pplayer->preftype = caps.ac_controls.b[0];
 
@@ -2087,7 +2087,7 @@ int nxplayer_playraw(FAR struct nxplayer_s *pplayer,
 void nxplayer_setmediadir(FAR struct nxplayer_s *pplayer,
      FAR const char *mediadir)
 {
-  strncpy(pplayer->mediadir, mediadir, sizeof(pplayer->mediadir));
+  strlcpy(pplayer->mediadir, mediadir, sizeof(pplayer->mediadir));
 }
 #endif
 
@@ -2312,7 +2312,7 @@ int nxplayer_systemreset(FAR struct nxplayer_s *pplayer)
 {
   struct dirent *pdevice;
   DIR           *dirp;
-  char           path[64];
+  char           path[PATH_MAX];
 
   /* Search for a device in the audio device directory */
 
diff --git a/system/nxplayer/nxplayer_main.c b/system/nxplayer/nxplayer_main.c
index dd670bf..777dc36 100644
--- a/system/nxplayer/nxplayer_main.c
+++ b/system/nxplayer/nxplayer_main.c
@@ -590,8 +590,8 @@ static int nxplayer_cmd_resume(FAR struct nxplayer_s 
*pplayer, char *parg)
 #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
 static int nxplayer_cmd_device(FAR struct nxplayer_s *pplayer, char *parg)
 {
-  int     ret;
-  char    path[32];
+  int  ret;
+  char path[PATH_MAX];
 
   /* First try to open the file directly */
 
@@ -738,8 +738,11 @@ static int nxplayer_cmd_help(FAR struct nxplayer_s 
*pplayer, char *parg)
 int main(int argc, FAR char *argv[])
 {
   char                    buffer[CONFIG_NSH_LINELEN];
-  int                     len, x, running;
-  char                    *cmd, *arg;
+  int                     len;
+  int                     x;
+  int                     running;
+  char                    *cmd;
+  char                    *arg;
   FAR struct nxplayer_s   *pplayer;
 
   printf("NxPlayer version " NXPLAYER_VER "\n");
diff --git a/system/nxrecorder/nxrecorder.c b/system/nxrecorder/nxrecorder.c
index fada84f..aa1abca 100644
--- a/system/nxrecorder/nxrecorder.c
+++ b/system/nxrecorder/nxrecorder.c
@@ -692,7 +692,7 @@ int nxrecorder_setdevice(FAR struct nxrecorder_s *precorder,
 
   /* Save the path and format capabilities of the device */
 
-  strncpy(precorder->device, pdevice, sizeof(precorder->device));
+  strlcpy(precorder->device, pdevice, sizeof(precorder->device));
 
   return OK;
 }
diff --git a/system/nxrecorder/nxrecorder_main.c 
b/system/nxrecorder/nxrecorder_main.c
index 15f741b..5e548cb 100644
--- a/system/nxrecorder/nxrecorder_main.c
+++ b/system/nxrecorder/nxrecorder_main.c
@@ -301,8 +301,8 @@ static int nxrecorder_cmd_resume(FAR struct nxrecorder_s 
*precorder,
 static int nxrecorder_cmd_device(FAR struct nxrecorder_s *precorder,
                                  FAR char *parg)
 {
-  int     ret;
-  char    path[32];
+  int  ret;
+  char path[PATH_MAX];
 
   /* First try to open the file directly */
 

Reply via email to