2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 21:07:47 +00:00

112 Commits

Author SHA1 Message Date
Aaron Conole
fb9410d844 checkpatch: Add file-parsing mode
This adds a new argument and feature, 'check-file', which will allow
checkpatch to run against files instead of only against patches.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:05:13 -08:00
Aaron Conole
a1193b4def checkpatch: fix the if and whitespace checks
The regex for the if/for/while bracket tests fails to distinguish
non-space text.  This means text such as do_something_if() would match
incorrectly.

Additionally, the ends-with-bracket test doesn't allow for the common
coding paradigm:

    if (condition) { /* Text about conditional. */
    }

So fix that as well.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:04:54 -08:00
Aaron Conole
83f76d4ef1 checkpatch: Fix signoff error
When no 'Signed-off-by' tags are found, the output will look like:

    E: No signatures found.
    E: Too many signoffs; are you missing Co-authored-by lines?
    Warnings: 0, Errors: 2

However, there should really only be one error reported in this case.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:04:35 -08:00
Aaron Conole
4d7f5e5136 checkpatch: Print file line numbers
The line numbers being printed were the line numbers for the patchfile.
This is sometimes okay to fix simple things (trailing or leading
whitespace, missing signoffs, etc).  But more complicated fixes, or
those fixes which require a bit more care, aren't helped by this.  So,
we use the implied file line number.

This can be useful with future work to 'mock' apply and build a real
contextual scanner for checking multi-line changes.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:04:18 -08:00
Aaron Conole
e3ecc9d35c checkpatch: convert some of the warnings
These coding issues are not just things that shouldn't be done.  They are
styles which should never be submitted.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:04:00 -08:00
Aaron Conole
7d6b834fe5 checkpatch: Print the line in question distinctly
This makes it easier to distinguish between the line, and
the warning/error message.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:03:24 -08:00
Aaron Conole
3239c7937c checkpatch: Announce the file where errors occur
This makes finding the warning and error marks much easier.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-11-28 17:01:05 -08:00
Aaron Conole
30c7ffd5ac utilities/checkpatch.py: Check for appropriate bracing
Teach checkpatch.py to understand that if/for/while blocks should always
end with braces on the same line (if possible). This does not address
multi-line if/for/while blocks, but provides a point where such blocks
could be added.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-05-20 10:07:50 -07:00
Daniele Di Proietto
c61e93d602 checkpatch: Accept form feeds.
CodingStyle.md says:

"Use form feeds (control+L) to divide long source files into logical
pieces.  A form feed should appear as the only character on a line."

checkpatch.py currently complains about form feed. For example, on
commit 2c06d9a927c5("ovstest: Add test-netlink-conntrack command."),
checkpatch.py returns:

    W(140): Line has non-spaces leading whitespace
    W(140): Line has trailing whitespace
    +

    W(177): Line has non-spaces leading whitespace
    W(177): Line has trailing whitespace
    +

    W(199): Line has non-spaces leading whitespace
    W(199): Line has trailing whitespace
    +

This commit suppresses the two warnings for lines with form feeds as the
only character.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ben Pfaff <blp@ovn.org>
2016-04-18 14:36:20 -07:00
Joe Stringer
6982ee960e checkpatch: Don't enforce char limit on tests.
Although tests ideally also stick to shorter line lengths, it is very
common for fixed text blocks like flows or large packets to be specified
within tests. Checkpatch shouldn't complain about cases like these.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
Tested-by: Aaron Conole <aconole@redhat.com>
2016-04-08 18:31:17 -07:00
Ben Pfaff
a5e9c53ce4 checkpatch: Fix Python style violation.
I introduced this when updating the script before commit.  My fault, sorry.

Fixes: c599d5ccf31 (checkpatch.py: A simple script for finding patch issues)
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-31 08:46:09 -07:00
Aaron Conole
c599d5ccf3 checkpatch.py: A simple script for finding patch issues
Most projects have a checkpatch facility, which can be used as a pre-commit
sanity check. This introduces such a mechanism to the Open vSwitch project
to catch some of the more silly formatting mistakes which can occur. It is
not meant to replace good code review practices, but it can help eliminate
the silly code review issues which get added.

Suggested-by: Mauricio Vásquez <mauricio.vasquezbernal@studenti.polito.it>
Signed-off-by: Aaron Conole <aconole@redhat.com>
[blp@ovn.org adjusted long line threshold and treatment of terminal]
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-31 08:29:14 -07:00