mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
tools/nxstyle.c: Correct false alarm detection (#106)
Commit cf5d17f795 added logic to detect #define pre-processor definitions outside of the "Pre-processor Definitions" file section. That commit was verified against numerous .c source files. But not against any .h header files.
When run against a header file, that change causes a false alarm warning like:
file:line:pos: warning: #define outside of 'Pre-processor Definitions' section
That is caused the idempotence, guard definition that must appear in the header file BEFORE the first file section.
This commit adds logic to nxstyle to ignore pre-processor definitions in header files that occur before the first file section is encountered.
This commit is contained in:
+16
-7
@@ -844,15 +844,24 @@ int main(int argc, char **argv, char **envp)
|
|||||||
{
|
{
|
||||||
if (g_section != PRE_PROCESSOR_DEFINITIONS)
|
if (g_section != PRE_PROCESSOR_DEFINITIONS)
|
||||||
{
|
{
|
||||||
/* Only a warning because there is some usage of
|
/* A complication is the header files always have
|
||||||
* define outside the Pre-processor Definitions
|
* the idempotence guard definitions before the
|
||||||
* section which is justifiable. Should be
|
* "Pre-processor Definitions section".
|
||||||
* manually checked.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WARN("#define outside of 'Pre-processor "
|
if (g_section == NO_SECTION &&
|
||||||
"Definitions' section",
|
g_file_type != C_HEADER)
|
||||||
lineno, ii);
|
{
|
||||||
|
/* Only a warning because there is some usage
|
||||||
|
* of define outside the Pre-processor
|
||||||
|
* Definitions section which is justifiable.
|
||||||
|
* Should be manually checked.
|
||||||
|
*/
|
||||||
|
|
||||||
|
WARN("#define outside of 'Pre-processor "
|
||||||
|
"Definitions' section",
|
||||||
|
lineno, ii);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user