Re: [RFC PATCH] checkpatch: Add warning for asymmetric brace use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2012-01-11 at 11:58 -0800, Joe Perches wrote:
> Here's a possible checkpatch patch.
> It seems to work on the test cases I've tried.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +				if ($seen) {
> +					my $sum_allowed = 0;
> +					foreach (@allowed) {
> +						$sum_allowed += $_;
> +					}
> +					if ($sum_allowed == 0) {
> +						WARN("BRACES",
> +						     "braces {} are not necessary for any arm of this statement\n" . $herectx);
> +					} elsif ($sum_allowed != $allow) {

I ran some more tests against the kernel source.
This works better as:

+					} elsif ($sum_allowed != $allow &&
+						 $seen != $allow) {

> +						WARN("BRACES",
> +						     "braces {} should be used on all arms of this statement\n" . $herectx);
> +					}



_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux