From 928fb2be6d2c2e8cf5980c09a3246e2820935400 Mon Sep 17 00:00:00 2001 From: liubojun1 Date: Wed, 31 Aug 2022 18:07:22 +0800 Subject: [PATCH] apps/system/nxplayer&nxlooper: fix codechecker warning nxplayer_main.c: code checker warning: level_percent = (uint8_t) atoi(parg); 'atoi' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead. nxlooper_main.c: code checker warning: percent = (uint16_t)(atof(parg) * 10.0); 'atof' used to convert a string to a floating-point value, but function will not report conversion errors; consider using 'strtod' instead Signed-off-by: liubojun1 --- system/nxlooper/nxlooper_main.c | 2 +- system/nxplayer/nxplayer_main.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/nxlooper/nxlooper_main.c b/system/nxlooper/nxlooper_main.c index ec4cd5601..b92b7d1b2 100644 --- a/system/nxlooper/nxlooper_main.c +++ b/system/nxlooper/nxlooper_main.c @@ -264,7 +264,7 @@ static int nxlooper_cmd_volume(FAR struct nxlooper_s *plooper, char *parg) { /* Get the percentage value from the argument */ - percent = (uint16_t)(atof(parg) * 10.0); + percent = (uint16_t)(strtof(parg, NULL) * 10.0f); return nxlooper_setvolume(plooper, percent); } diff --git a/system/nxplayer/nxplayer_main.c b/system/nxplayer/nxplayer_main.c index 052fadab8..c1f7f9dc0 100644 --- a/system/nxplayer/nxplayer_main.c +++ b/system/nxplayer/nxplayer_main.c @@ -415,7 +415,7 @@ static int nxplayer_cmd_bass(FAR struct nxplayer_s *pplayer, char *parg) { /* Get the level and range percentage value from the argument */ - level_percent = (uint8_t) atoi(parg); + level_percent = (uint8_t)strtoul(parg, NULL, 10); nxplayer_setbass(pplayer, level_percent); } @@ -445,7 +445,7 @@ static int nxplayer_cmd_treble(FAR struct nxplayer_s *pplayer, char *parg) { /* Get the level and range percentage value from the argument */ - level_percent = (uint8_t) atoi(parg); + level_percent = (uint8_t)strtoul(parg, NULL, 10); nxplayer_settreble(pplayer, level_percent); } @@ -476,7 +476,7 @@ static int nxplayer_cmd_balance(FAR struct nxplayer_s *pplayer, char *parg) { /* Get the percentage value from the argument */ - percent = (uint16_t) (atof(parg) * 10.0); + percent = (uint16_t)(strtof(parg, NULL) * 10.0f); nxplayer_setbalance(pplayer, percent); }