Commit Graph

68 Commits

Author SHA1 Message Date
Johanne Schock
62c2b4aac7 nxstyle fixes
fixed coloumn number of error messages PR #487
fixed lineno_min = lineno_min
2020-03-08 07:29:30 -06:00
Johanne Schock
77d02e98a0 Implemented comment processing for preprocessor lines 2020-03-08 06:36:54 -06:00
David Sidrane
c5b4d9b628 nxstyle:nxstyle should pass nxstyle checks! 2020-03-07 08:31:36 -06:00
David Sidrane
8b1dc2825f Update nxstyle.c 2020-03-06 15:49:59 -06:00
YAMAMOTO Takashi
45a8edd227 nxstyle: Output line numbers when complaining on block comments length 2020-03-06 07:25:52 -06:00
YAMAMOTO Takashi
0715ab3132 Revert "tools/nxstyle: Back out part of last commit. Logic to avoid some false alarms was causing real style problems from being reported."
If we are going to use this tool for things like
git pre-commit hook or CI workflow, it's critical to
avoid false alarms.

This reverts commit de764af9aa.
2020-03-06 07:25:11 -06:00
YAMAMOTO Takashi
4879f2225e nxstyle: Don't complain on ELF things like Elf32_Hdr 2020-03-05 21:18:12 -06:00
YAMAMOTO Takashi
e5ea0ac32d nxstyle: Don't parse a file if its type is unknown 2020-03-05 20:18:11 -06:00
Gregory Nutt
75e3af0985 tools/nxstyle: Allow mixed case system calls.
System calls have mixed case.  They begin with SYS_ but then are followed by the system function name in lower case.
2020-02-14 17:22:18 +01:00
Gregory Nutt
dfcbc42679 tools/nxstyle.c: Fix logic error in previous change. 2020-02-03 22:26:28 +01:00
Gregory Nutt
2483b65bfb tools/nxstyle.c: Ignore inttypes.h constants.
Eliminate warnings.  Ignore mixed case identifies beginning with PRIx.
These most likely come from inttypes.h and we nxstyle must tolerate
those definitions even though they do not follow the coding style.
2020-02-03 17:51:09 +01:00
Gregory Nutt
94483cf400 tools/nxstyle.c: Add logic to detect check for left brace in first column, but preceded by a blank line. That should never happen for the outermost opening branch (but could happen with internal compound statements).
Consider junk.c for example:

    /****************************************************************************
     * xx
     ****************************************************************************/

    /****************************************************************************
     * Private Types
     ****************************************************************************/

    struct foo_s

    {
      int bar;
    };

    /****************************************************************************
     * Public Functions
     ****************************************************************************/

    int dofoo(int barin)

    {
      barout = barin;
      return barout;
    }

nxstyle not detects these problems:

    $ tools/nxstyle.exe junk.c
    junk.c:11:0: error: Blank line before opening left brace
    junk.c:21:0: error: Blank line before opening left brace
2020-01-28 12:26:01 -03:00
patacongo
0e77e3373e 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.
2020-01-15 20:22:37 +00:00
Gregory Nutt
cf5d17f795 tools/nxstyle: Added logic to parse section headers (#90)
* tools/nxstyle:  Added logic to parse section headers (like Included files, Pre-processor Definitions, etc.) and to assure that the section headers are correct for the file type.  Also (1) verify that #include appears only in the 'Included Files' section and that (2) #define only occurs in the Pre-processor definition section.

    Right now, there are several places where that rule is not followed.  I think most of these are acceptable so these failures only generate warnings, not errors.  The warning means that we need to go look at the offending #define or #include and decide if it is a acceptable usage or not.
2020-01-13 18:08:45 +00:00
Gregory Nutt
beae24c8c0 tools/nxstyle.c: Correct indexing error noted by Xaio Xaing in commit comments. 2020-01-12 14:52:48 -03:00
Gregory Nutt
6309165fe0 tools/nxstyle.c: Add automatic detection of line width based on examining
the width of all block comments. Includes a check to assure that all block
comments use the same line width.

Verified against all .c files under /sched.  There were a few cosmetic changes to the coding style under /sched to account to new, correctly detected problems in the /sched files.
2020-01-12 13:07:54 -03:00
liuguo09
1c53d2b616 Nxstyle checkpatch support (#47)
* tools/nxstyle.c: Donot check unknown file extension files

nxstyle only support c soure file and header file check, donot check
other unknown file extension files.

* tools/checkpatch.sh: Add checkpatch.sh script based on nxstyle tool

Usage:
checkpatch.sh patch-list // default as patch list
checkpatch.sh -p patch-list
checkpatch.sh -c commit-list
checkpatch.sh -f file-list
checkpatch.sh - // read from stdin, which used by git pre-commit hook

And git pre-commit hook could use checkpatch.sh as below:
git diff --cached | ./tools/checkpatch.sh -
2020-01-07 08:14:01 -06:00
liuhaitao
7da409f3b5 tools/nxstyle.c: Add -r option to check specified range lines
Usage: ./nxstyle -r start,count filename

nxstyle with -r option used to parse the range lines rather than the whole file.

Change-Id: I58ec56511fde14d6ec914400a7849e69960a3711
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-01-04 07:58:00 -06:00
David Sidrane
002772c81e nxstyle improvements with No tooling (#12)
tools/nxstyle.c:  Output compiler like error format.  Added features

   Uses getops to pars command line.
   Supports
      -s silence all output
      -g provide a PASS fail message

* tools/README.txt:  Update with new nxstyle options
2019-12-30 21:01:41 -06:00
Gregory Nutt
504b0e8b5b drivers/wireless: Run all wireless drivers through tools/nxstyle, correcting as many complaints as possible. 2019-12-05 11:49:12 -06:00
Gregory Nutt
d87295f328 tools/Directories.mk, Makefile.*: Extend the clean_context target so that it will remove the autogenerated files created during the context phase of the initial build. 2019-12-03 06:38:53 -06:00
Gregory Nutt
d2af57169b tools/nxstyle.c: Fix a rare false alarm that could occur if a variable or function name begins with the sub-string 'union' or 'struct'. misc fixes under fs/ and sched/ from application of current version of nxstyle. 2019-12-01 13:01:16 -06:00
Gregory Nutt
91d04837e9 tools/nxstyle.c: Eliminate some false alarms related to comments to the right of code about alignment and spacing. 2019-12-01 11:37:30 -06:00
Gregory Nutt
8bc55d4396 tools/nxstyle.c: Trivial improvement to preceding change to allow white space separation. 2019-11-19 11:43:20 -06:00
Gregory Nutt
f3c2022b4e tools/nxstyle: Fix false alarm 'Garbage follows right bracket' on named structures that are fields of other structures or unions. 2019-11-19 11:32:57 -06:00
Gregory Nutt
a9ef2b4208 tools/nxstyle.c: Eliminate false positive 'Invalid character after asterisk in comment block'. 2019-11-09 12:10:43 -06:00
Matias Nitsche
e118d99bf5 drivers/power/pm: Historically, the NuttX PM subsystem has consisted of two functional components: (1) an "Upper" part that detects state changes based on a random walk driven by activity levels, and (2) and "lower" part that implementst the state changes.
This change decouples that upper activity-based logic from the lower random walk logic and allows use of other upper state detection logic (such as a custom, application-specific state machine).
2019-11-09 09:09:33 -06:00
Gregory Nutt
2ab4d635b4 tools/nxstyle.c: Correct detection of missing blank line following a block comment. 2019-11-09 08:15:12 -06:00
Gregory Nutt
ad9dc2b608 tools/nxstyle.c: Eliminate false alarms when checking for alignment of comments to the right of code. Fix check for C++ style comments so that strings like http:// and https:// do not generate false alarms. 2019-10-27 11:45:33 -06:00
Gregory Nutt
a4997d6a2c tools/nxstyle.c: Eliminate false alarm errors on comments that are to the right of code when the comment terminator is on the same line as the last of the comment. 2019-10-25 12:34:42 -06:00
Gregory Nutt
b5111d2c38 tools/nxstyle.c: Add logic to detect if there is a blank line following the final right brace. sched/: Applied the modified nxstyle to all C file as a test. 2019-10-24 11:02:42 -06:00
Gregory Nutt
005a8a606f tools/nxstyle.c: Add detection of carriage returns. Improve reporting of TABs. 2019-10-23 12:49:27 -06:00
Gregory Nutt
53119cd476 tools/nxstyle.c: No warning for declarations that begin in column 1 within 'extern "C"'. This is because the 'extern "C"' is conditioned on __cplusplus so the declarations are not normally indented. 2019-06-30 15:10:14 -06:00
Gregory Nutt
bde0509cae tools/nxstyle.c: Fix error in conditional logic that was preventing detection bad brace alignment. Add logic to handle alignment of braces in data initializators which following slightly different indentation rules. 2019-06-30 10:35:10 -06:00
Gregory Nutt
f6221ae2dc tools/nxstyle.c: Fix logic from commit 005a077310 for the case of header files when contain no functions. 2019-06-29 18:38:56 -06:00
Gregory Nutt
42b178fb13 tools/nxstyle.c: Bandaid-up logic that detects left brackets on the same line in global structure/enumeration types and initializers. 2019-06-29 16:19:10 -06:00
Gregory Nutt
35521ab2b6 Fix some new warnings found in build testing. 2019-06-29 13:24:38 -06:00
Gregory Nutt
005a077310 tools/nxstyle.c: Tool depends on the file under test containing "Private Functions" or "Public Functions" block comments. Emit an error is neither are present. 2019-06-29 11:43:37 -06:00
Gregory Nutt
04fe412414 tools/nxstyle.c: Costmetic alignment and corrections to comments. 2019-03-13 07:05:31 -06:00
Gregory Nutt
4802eb65c5 tools/nxstyle.c: Fix a bacward test in the previous commit. 2019-03-12 14:48:43 -06:00
Gregory Nutt
ba859ad302 tools/nxstyle.c: Don't complain about certain lowercase characters in otherwise uppercase pre-processor identifers: IPv6, IPv4, ICMPv6, IGMPv2, p as a decimal point, d signifying a divisor. It was a bad idea to let the door open a crack for there. While they improve readability, the inconsistently also causes other problems. 2019-03-12 14:22:52 -06:00
Gregory Nutt
f6b00e1966 tools/nxstyle.c: Fix logic error that prevent detecion of '/' and '/=' as operators. net/: Minor updates resulting from testing tools/nxstyle. 2019-03-11 12:48:39 -06:00
Gregory Nutt
aa4f7c9ba7 graphics/nxmu/nxmu_start.c: Extend nxmu_start so that receives a display number as an argument. This makes it possible to have multiple instances of the NX server running on boards that support multiple displays. Also includes updates to boardctl() to accept display number paramters. 2019-03-10 13:50:05 -06:00
Gregory Nutt
f6b9fe5b14 tools/nxstyle.c: Add logic to detect a blank line following a left brace or a blank line preceding a right brace. 2019-03-10 09:53:33 -06:00
Gregory Nutt
cf0f0e69f8 tools/nxstyle.c: Was confusing hex constants with strings staring with 'x'. Added logic to complain about hex constants containing upper case characters. 2019-03-09 09:21:12 -06:00
Gregory Nutt
c8004c7e00 tools/nxstyle.c: Add capability to detect CamelCase identifiers. 2019-03-05 13:08:57 -06:00
Gregory Nutt
f914ec6e2b tools/nxstyle.c: Fix logic that detects if an operator is correctly delimited with spaces. sched/: Various changes because sched/ C files were used as Guinea Pigs to test nstyle.c. 2019-03-01 10:50:02 -06:00
Gregory Nutt
c13afc29e6 Trivial, Costmetic, ... 2019-02-27 14:02:53 -06:00
Gregory Nutt
bc5908d9fd tools/nxstyle.c: Beef up logic that detects multiple variable definitions per line. 2019-02-17 10:57:28 -06:00
Gregory Nutt
b5e6af60ac tools/nxstyle.c: Add check for multiple definitions of local variables on a line. 2019-02-14 18:33:23 -06:00