This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit d22949b9a680a3a4165da7ecfc2b842dde8d09bb
Author: shenjunyuan <[email protected]>
AuthorDate: Fri Nov 13 15:26:49 2026 +0800

    system/nxinit: cast isblank() arguments to unsigned char
    
    Passing a plain char to isblank() may yield a negative value other
    than EOF on signed-char target, which violates MISRA C:2012 Rule
    21.13 and is undefined behavior. Cast the arguments to unsigned char.
    
    Signed-off-by: shenjunyuan <[email protected]>
    Signed-off-by: wangjianyu3 <[email protected]>
---
 system/nxinit/parser.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/system/nxinit/parser.c b/system/nxinit/parser.c
index e3f37ee15..3f3b6c878 100644
--- a/system/nxinit/parser.c
+++ b/system/nxinit/parser.c
@@ -62,7 +62,7 @@ static int init_parse_config_lines(FAR const struct parser_s 
*parser,
        * lines (the first character that is not whitespace is '#').
        */
 
-      for (ret = 0; buf[ret] && isblank(buf[ret]); ret++);
+      for (ret = 0; buf[ret] && isblank((unsigned char)buf[ret]); ret++);
 
       if (buf[ret] == '\0' || buf[ret] == '#')
         {
@@ -165,7 +165,7 @@ int init_parse_arguments(FAR char *buf, bool dup, int argc, 
FAR char **argv)
 
   for (; ; )
     {
-      while (isblank(*buf))
+      while (isblank((unsigned char)*buf))
         {
           if (!quote)
             {
@@ -177,7 +177,7 @@ int init_parse_arguments(FAR char *buf, bool dup, int argc, 
FAR char **argv)
         }
 
       if (*buf == '-' && *(buf + 1) == '-'
-          && (isblank(*(buf + 2)) || *(buf + 2) == '\0'))
+          && (isblank((unsigned char)*(buf + 2)) || *(buf + 2) == '\0'))
         {
           argv[i++] = buf;
           if (i >= argc || *(buf += 2) == '\0')
@@ -185,7 +185,7 @@ int init_parse_arguments(FAR char *buf, bool dup, int argc, 
FAR char **argv)
               break;
             }
 
-          while (isblank(*buf))
+          while (isblank((unsigned char)*buf))
             {
               *buf++ = '\0';
             }

Reply via email to