mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
checkpatch.pl: check single statement brace
This commit is contained in:
parent
b149526d03
commit
c4b9173afd
2 changed files with 23 additions and 1 deletions
21
scripts/checkpatch.pl
vendored
21
scripts/checkpatch.pl
vendored
|
|
@ -5508,11 +5508,32 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
# We need this for the labwc-custom check below. It
|
||||
# avoids false positives with do { } while (); etc.
|
||||
my $starts_with_if_while_etc = 0;
|
||||
if ($s =~ /^\+\s*(if|while|for|switch).*/) {
|
||||
$starts_with_if_while_etc = 1;
|
||||
}
|
||||
|
||||
# Find out what is on the end of the line after the
|
||||
# conditional.
|
||||
substr($s, 0, length($c), '');
|
||||
$s =~ s/\n.*//g;
|
||||
$s =~ s/$;//g; # Remove any comments
|
||||
|
||||
# Find if/while/for/switch without opening braces
|
||||
# because (as opposed to Linux coding style) we use
|
||||
# braces for single statement blocks.
|
||||
#
|
||||
# include/ssd-internal.h contains a macro that we can't
|
||||
# deal with, so ignore that
|
||||
#
|
||||
if ($starts_with_if_while_etc && !length($s)
|
||||
&& $filename ne "include/ssd-internal.h") {
|
||||
CHK("BRACES", "[labwc-custom] open brace { expected after if/while/for/switch - even with single statement blocks");
|
||||
}
|
||||
|
||||
if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
|
||||
$c !~ /}\s*while\s*/)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@
|
|||
static int
|
||||
round_to_increment(int val, int base, int inc)
|
||||
{
|
||||
if (base < 0 || inc <= 0)
|
||||
if (base < 0 || inc <= 0) {
|
||||
return val;
|
||||
}
|
||||
return base + (val - base + inc / 2) / inc * inc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue