diff mbox

[ovs-dev,3/4] checkpatch: Allow checking more than one file.

Message ID 1500029844-846-4-git-send-email-i.maximets@samsung.com
State Accepted
Headers show

Commit Message

Ilya Maximets July 14, 2017, 10:57 a.m. UTC
Currently to check more than one patch or file it's required
to invoke script for each file separately.
Fix that by iterating over all the passed filenames.

Note: If '-f' option passed, all the files treated as usual files.
      Without '-f' all the files treated as patch files.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 utilities/checkpatch.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Aaron Conole July 17, 2017, 6:47 p.m. UTC | #1
Ilya Maximets <i.maximets@samsung.com> writes:

> Currently to check more than one patch or file it's required
> to invoke script for each file separately.
> Fix that by iterating over all the passed filenames.
>
> Note: If '-f' option passed, all the files treated as usual files.
>       Without '-f' all the files treated as patch files.
>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>
diff mbox

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 4a92890..7ccec51 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -408,7 +408,7 @@  def usage():
 Open vSwitch checkpatch.py
 Checks a patch for trivial mistakes.
 usage:
-%s [options] [PATCH | -f SOURCE | -1 | -2 | ...]
+%s [options] [PATCH1 [PATCH2 ...] | -f SOURCE1 [SOURCE2 ...] | -1 | -2 | ...]
 
 Input options:
 -f|--check-file                Arguments are source files, not patches.
@@ -513,13 +513,18 @@  if __name__ == '__main__':
                 status = -1
         sys.exit(status)
 
-    try:
-        filename = args[0]
-    except:
+    if not args:
         if sys.stdin.isatty():
             usage()
             sys.exit(-1)
         result = ovs_checkpatch_parse(sys.stdin.read(), '-')
         ovs_checkpatch_print_result(result)
         sys.exit(result)
-    sys.exit(ovs_checkpatch_file(filename))
+
+    status = 0
+    for filename in args:
+        print('== Checking "%s" ==' % filename)
+        result = ovs_checkpatch_file(filename)
+        if result:
+            status = -1
+    sys.exit(status)