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/incubator-nuttx-apps.git

commit 65a02ba9f9ed776089d8446985ecb14aa9a6cb71
Author: Xiang Xiao <[email protected]>
AuthorDate: Sun Mar 6 17:58:50 2022 +0800

    system/nxplayer: Fix the compiler warning
    
    nxplayer.c: In function 'nxplayer_playinternal':
    Error: nxplayer.c:209:36: error: '%s' directive output may be truncated 
writing up to 99 bytes into a region of size 59 [-Werror=format-truncation=]
      209 |   snprintf(buf, sizeof(buf), "GET /%s HTTP/1.0\r\n\r\n", relurl);
          |                                    ^~                    ~~~~~~
    nxplayer.c:209:3: note: 'snprintf' output between 19 and 118 bytes into a 
destination of size 64
      209 |   snprintf(buf, sizeof(buf), "GET /%s HTTP/1.0\r\n\r\n", relurl);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error: nxplayer.c:1809:42: error: 'snprintf' output may be truncated before 
the last format character [-Werror=format-truncation=]
     1809 |       snprintf(path, sizeof(path), "%s/%s", pplayer->mediadir, 
pfilename);
          |                                          ^
    nxplayer.c:1809:7: note: 'snprintf' output 2 or more bytes (assuming 129) 
into a destination of size 128
     1809 |       snprintf(path, sizeof(path), "%s/%s", pplayer->mediadir, 
pfilename);
          |       
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error: nxplayer.c:359:53: error: '%s' directive output may be truncated 
writing up to 128 bytes into a region of size 53 [-Werror=format-truncation=]
      359 |           snprintf(path,  sizeof(path), "/dev/audio/%s", 
pdevice->d_name);
          |                                                     ^~
    nxplayer.c:359:11: note: 'snprintf' output between 12 and 140 bytes into a 
destination of size 64
      359 |           snprintf(path,  sizeof(path), "/dev/audio/%s", 
pdevice->d_name);
          |           
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 system/nxplayer/nxplayer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/system/nxplayer/nxplayer.c b/system/nxplayer/nxplayer.c
index 8dc1df9..a4e0c8e 100644
--- a/system/nxplayer/nxplayer.c
+++ b/system/nxplayer/nxplayer.c
@@ -148,7 +148,7 @@ static int _open_with_http(const char *fullurl)
   char resp_msg[] = "\r\n\r\n";
   struct timeval tv;
   uint16_t port = 80;
-  char buf[64];
+  char buf[PATH_MAX];
   int  s;
   int  n;
   char c;
@@ -317,7 +317,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s 
*pplayer, int format,
       struct audio_caps_s caps;
       FAR struct dirent *pdevice;
       FAR DIR *dirp;
-      char path[64];
+      char path[PATH_MAX];
       uint8_t supported = true;
       uint8_t x;
 
@@ -1778,7 +1778,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s 
*pplayer,
   struct audio_caps_desc_s cap_desc;
   struct ap_buffer_info_s  buf_info;
 #ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
-  char                path[128];
+  char                path[PATH_MAX];
 #endif
   int                 tmpsubfmt = AUDIO_FMT_UNDEF;
   int                 ret;

Reply via email to