[PATCH RESEND 01/13] scripts/checkpatch.pl: Detect superfluous semicolon in C code

Philippe Mathieu-Daudé posted 13 patches 5 years, 8 months ago
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>, Max Reitz <mreitz@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Alistair Francis <alistair@alistair23.me>, Fam Zheng <fam@euphon.net>, Thomas Huth <thuth@redhat.com>, Thomas Huth <huth@tuxfamily.org>, Aarushi Mehta <mehta.aaru20@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Richard Henderson <rth@twiddle.net>, Peter Maydell <peter.maydell@linaro.org>, Julia Suvorova <jusual@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Alex Williamson <alex.williamson@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Juan Quintela <quintela@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
[PATCH RESEND 01/13] scripts/checkpatch.pl: Detect superfluous semicolon in C code
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
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>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ce43a306f8..11512a8a09 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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);
-- 
2.21.1


Re: [PATCH RESEND 01/13] scripts/checkpatch.pl: Detect superfluous semicolon in C code
Posted by Juan Quintela 5 years, 8 months ago
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> 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>

Reviewed-by: Juan Quintela <quintela@redhat.com>


Re: [PATCH RESEND 01/13] scripts/checkpatch.pl: Detect superfluous semicolon in C code
Posted by Luc Michel 5 years, 8 months ago
On 2/18/20 10:43 AM, Philippe Mathieu-Daudé wrote:
> 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>

Reviewed-by: Luc Michel <luc.michel@greensocs.com>

> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/checkpatch.pl | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index ce43a306f8..11512a8a09 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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);
> 

Re: [PATCH RESEND 01/13] scripts/checkpatch.pl: Detect superfluous semicolon in C code
Posted by Dr. David Alan Gilbert 5 years, 8 months ago
* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> 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>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/checkpatch.pl | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index ce43a306f8..11512a8a09 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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);
> -- 
> 2.21.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK