summaryrefslogtreecommitdiffstats
path: root/util/check-format.pl
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-04-28 21:45:07 +0200
committerDr. David von Oheimb <dev@ddvo.net>2021-05-20 16:29:13 +0200
commitff3810332483f79b55f90db0ca9f93145d8f06b5 (patch)
tree216593546ab0baa2b5a9a861ca394081eb793f4d /util/check-format.pl
parentf14bead2c4898e484b6c01808c07edf3b61f01e9 (diff)
check-format.pl: Add check for constant left of comparison operator
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15077)
Diffstat (limited to 'util/check-format.pl')
-rwxr-xr-xutil/check-format.pl7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/check-format.pl b/util/check-format.pl
index 2a9adc6fb8..481eda8b36 100755
--- a/util/check-format.pl
+++ b/util/check-format.pl
@@ -846,7 +846,12 @@ while (<>) { # loop over all lines of all input files
}
}
- report("one-letter name '$2'") if (m/(^|.*\W)([lIO])(\W.*|$)/); # single-letter name 'l', 'I', or 'O'
+ report("single-letter name '$2'") if (m/(^|.*\W)([IO])(\W.*|$)/); # single-letter name 'I' or 'O' # maybe re-add 'l'?
+ # constant on LHS of comparison or assignment, e.g., NULL != x or 'a' < c, but not a + 1 == b
+ report("constant on LHS of '$2'")
+ if (m/(['"]|([\+\-\*\/\/%\&\|\^<>]\s*)?\W[0-9]+L?|NULL)\s*([\!<>=]=|[<=>][^<>])/ && $2 eq "");
+
+ # TODO report #if 0 and #if 1
# TODO report empty line within local variable definitions