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 <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-06 17:58:50 +08:00 committed by Xiang Xiao
parent 44b92d9254
commit 65a02ba9f9

View File

@ -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;