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 <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
2fc7c67031
commit
d364d7a810
@ -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 */
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user