diff mbox

[ovs-dev] checkpatch: Implement -f option more usefully.

Message ID 20170526182236.22764-1-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff May 26, 2017, 6:22 p.m. UTC
A lot of checkpatch warnings are only enabled for particular kinds of
files, e.g. C warnings only apply to C source and header files.  The -f
option didn't pass the file name to the code that determines what kinds
of warnings to report, so only generic warnings were actually reported.
This fixes that problem.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 utilities/checkpatch.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Aaron Conole May 30, 2017, 8:23 p.m. UTC | #1
Ben Pfaff <blp@ovn.org> writes:

> A lot of checkpatch warnings are only enabled for particular kinds of
> files, e.g. C warnings only apply to C source and header files.  The -f
> option didn't pass the file name to the code that determines what kinds
> of warnings to report, so only generic warnings were actually reported.
> This fixes that problem.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---

Makes sense, and looks good to me.

Acked-by: Aaron Conole <aconole@redhat.com>
Ben Pfaff May 31, 2017, 3:57 p.m. UTC | #2
On Tue, May 30, 2017 at 04:23:11PM -0400, Aaron Conole wrote:
> Ben Pfaff <blp@ovn.org> writes:
> 
> > A lot of checkpatch warnings are only enabled for particular kinds of
> > files, e.g. C warnings only apply to C source and header files.  The -f
> > option didn't pass the file name to the code that determines what kinds
> > of warnings to report, so only generic warnings were actually reported.
> > This fixes that problem.
> >
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> 
> Makes sense, and looks good to me.
> 
> Acked-by: Aaron Conole <aconole@redhat.com>

Thanks!  I applied this to master.
diff mbox

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 443b8c0481c2..295ecd4537bb 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -276,13 +276,13 @@  def run_checks(current_file, line, lineno):
         print("%s\n" % line)
 
 
-def ovs_checkpatch_parse(text):
-    global print_file_name, total_line
+def ovs_checkpatch_parse(text, filename):
+    global print_file_name, total_line, checking_file
     lineno = 0
     signatures = []
     co_authors = []
     parse = 0
-    current_file = ''
+    current_file = filename if checking_file else ''
     previous_file = ''
     scissors = re.compile(r'^[\w]*---[\w]*')
     hunks = re.compile('^(---|\+\+\+) (\S+)')
@@ -387,7 +387,7 @@  def ovs_checkpatch_file(filename):
     for part in mail.walk():
         if part.get_content_maintype() == 'multipart':
             continue
-    result = ovs_checkpatch_parse(part.get_payload(decode=True))
+    result = ovs_checkpatch_parse(part.get_payload(decode=True), filename)
     if result < 0:
         print("Lines checked: %d, Warnings: %d, Errors: %d" %
               (total_line, __warnings, __errors))
@@ -436,5 +436,5 @@  if __name__ == '__main__':
         if sys.stdin.isatty():
             usage()
             sys.exit(-1)
-        sys.exit(ovs_checkpatch_parse(sys.stdin.read()))
+        sys.exit(ovs_checkpatch_parse(sys.stdin.read()), '-')
     sys.exit(ovs_checkpatch_file(filename))