You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2023/01/25 21:44:12 UTC

[nuttx-apps] branch master updated: apps/system/nxplayer&nxlooper: fix codechecker warning

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


The following commit(s) were added to refs/heads/master by this push:
     new 928fb2be6 apps/system/nxplayer&nxlooper:  fix codechecker warning
928fb2be6 is described below

commit 928fb2be6d2c2e8cf5980c09a3246e2820935400
Author: liubojun1 <li...@xiaomi.com>
AuthorDate: Wed Aug 31 18:07:22 2022 +0800

    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 <li...@xiaomi.com>
---
 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);
     }