tools/nxstyle: add white files list to allow assembly headers to pass ci checks

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-04-26 17:27:43 +08:00
committed by Xiang Xiao
parent 9fa097ab69
commit c87da0d115
+50 -6
View File
@@ -221,7 +221,7 @@ static const char *g_white_suffix[] =
NULL
};
static const char *g_white_list[] =
static const char *g_white_content_list[] =
{
/* Ref: gnu_unwind_find_exidx.c */
@@ -551,6 +551,19 @@ static const char *g_white_headers[] =
NULL
};
static const char *g_white_files[] =
{
/* Skip assembler file headers
* Ref:
* libs/libc/machine/arm/arm-acle-compat.h
* libs/libc/machine/arm/arm_asm.h
*/
"arm-acle-compat.h",
"arm_asm.h",
NULL
};
/********************************************************************************
* Private Functions
********************************************************************************/
@@ -904,14 +917,40 @@ static bool check_section_header(const char *line, int lineno)
}
/********************************************************************************
* Name: white_prefix
* Name: white_file_list
*
* Description:
* Return true if the filename string with a white-listed name
*
********************************************************************************/
static bool white_file_list(const char *filename)
{
const char **pptr;
const char *str;
for (pptr = g_white_files;
(str = *pptr) != NULL;
pptr++)
{
if (strstr(filename, str) != NULL)
{
return true;
}
}
return false;
}
/********************************************************************************
* Name: white_content_list
*
* Description:
* Return true if the identifier string begins with a white-listed prefix
*
********************************************************************************/
static bool white_list(const char *ident, int lineno)
static bool white_content_list(const char *ident, int lineno)
{
const char **pptr;
const char *str;
@@ -956,7 +995,7 @@ static bool white_list(const char *ident, int lineno)
}
}
for (pptr = g_white_list;
for (pptr = g_white_content_list;
(str = *pptr) != NULL;
pptr++)
{
@@ -1102,6 +1141,11 @@ int main(int argc, char **argv, char **envp)
return 0;
}
if (white_file_list(g_file_name))
{
return 0;
}
instream = fopen(g_file_name, "r");
if (!instream)
@@ -1508,7 +1552,7 @@ int main(int argc, char **argv, char **envp)
"section",
lineno, ii);
}
else if (white_list(&line[ii], lineno))
else if (white_content_list(&line[ii], lineno))
{
g_skipmixedcase = true;
}
@@ -2049,7 +2093,7 @@ int main(int argc, char **argv, char **envp)
/* Ignore symbols that begin with white-listed prefixes */
if (g_skipmixedcase ||
white_list(&line[ident_index], lineno))
white_content_list(&line[ident_index], lineno))
{
/* No error */
}