OSDN Git Service

scripts/checkpatch.pl: Detect superfluous semicolon in C code
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Tue, 18 Feb 2020 09:43:50 +0000 (10:43 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Tue, 18 Feb 2020 19:20:49 +0000 (20:20 +0100)
Display error when a commit contains superfluous semicolon:

  $ git show 6663a0a3376 | scripts/checkpatch.pl -q -
  ERROR: superfluous trailing semicolon
  #276: FILE: block/io_uring.c:186:
  +                ret = -ENOSPC;;
  total: 1 errors, 1 warnings, 485 lines checked

Reported-by: Luc Michel <luc.michel@greensocs.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Message-Id: <20200218094402.26625-2-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
scripts/checkpatch.pl

index ce43a30..11512a8 100755 (executable)
@@ -1830,6 +1830,11 @@ sub process {
                        ERROR("suspicious ; after while (0)\n" . $herecurr);
                }
 
+# Check superfluous trailing ';'
+               if ($line =~ /;;$/) {
+                       ERROR("superfluous trailing semicolon\n" . $herecurr);
+               }
+
 # Check relative indent for conditionals and blocks.
                if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
                        my ($s, $c) = ($stat, $cond);