From b2f3a4b5f924b066a7f9922e84e7cdb0188145e3 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 23 Jun 2020 00:14:42 +0800 Subject: [PATCH] tools/nxstyle: Support the white list and add _Exit to the white list Signed-off-by: Xiang Xiao --- tools/nxstyle.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/nxstyle.c b/tools/nxstyle.c index 78351334bf..9a3a4717ec 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 */ }