You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/06/28 20:08:10 UTC

[incubator-nuttx] branch master updated: tools/nxstyle: Support the white list

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b2f3a4b  tools/nxstyle: Support the white list
b2f3a4b is described below

commit b2f3a4b5f924b066a7f9922e84e7cdb0188145e3
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Jun 23 00:14:42 2020 +0800

    tools/nxstyle: Support the white list
    
    and add _Exit to the white list
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 tools/nxstyle.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 7835133..9a3a471 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -195,6 +195,12 @@ static const char *g_white_prefix[] =
   NULL
 };
 
+static const char *g_white_list[] =
+{
+  "_Exit",   /* Ref:  stdlib.h */
+  NULL
+};
+
 /********************************************************************************
  * Private Functions
  ********************************************************************************/
@@ -502,7 +508,7 @@ static bool check_section_header(const char *line, int lineno)
  *
  ********************************************************************************/
 
-static bool white_prefix(const char *ident, int lineno)
+static bool white_list(const char *ident, int lineno)
 {
   const char **pptr;
   const char *str;
@@ -517,6 +523,19 @@ static bool white_prefix(const char *ident, int lineno)
         }
     }
 
+  for (pptr = g_white_list;
+       (str = *pptr) != NULL;
+       pptr++)
+    {
+      size_t len = strlen(str);
+
+      if (strncmp(ident, str, len) == 0 &&
+          isalnum(ident[len]) == 0)
+        {
+          return true;
+        }
+    }
+
   return false;
 }
 
@@ -1485,7 +1504,7 @@ int main(int argc, char **argv, char **envp)
                 {
                   /* Ignore symbols that begin with white-listed prefixes */
 
-                  if (white_prefix(&line[ident_index], lineno))
+                  if (white_list(&line[ident_index], lineno))
                     {
                       /* No error */
                     }