summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2022-01-06 22:05:22 +0100
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2022-07-20 13:06:27 +0200
commitf5650553da65af29c406edaab0fdbe688935f75f (patch)
treeec30ceecd55ac5a610e5a8f351dd6aa44dcfb8a5 /util
parentac2a419e5175dc3c70ab7c85dd6d41bf5d870de3 (diff)
check-format.pl: Fix report on constant on LHS of comparison/assignment
Reviewed-by: Paul Dale <pauli@openssl.org> (cherry picked from commit 15ae69fa7bc0f367edded19bc48e6d9a5ce8d547)
Diffstat (limited to 'util')
-rw-r--r--util/check-format-test-negatives.c1
-rwxr-xr-xutil/check-format.pl3
2 files changed, 3 insertions, 1 deletions
diff --git a/util/check-format-test-negatives.c b/util/check-format-test-negatives.c
index f4c0908e4c..8f6ed23ee7 100644
--- a/util/check-format-test-negatives.c
+++ b/util/check-format-test-negatives.c
@@ -188,6 +188,7 @@ int f(void) /*
/* should not trigger: constant on LHS of comparison or assignment operator */
X509 *x509 = NULL;
int y = a + 1 < b;
+int ret, was_NULL = *certs == NULL;
const OPTIONS passwd_options[] = {
{"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
diff --git a/util/check-format.pl b/util/check-format.pl
index aa2566e28e..8861b2bd8a 100755
--- a/util/check-format.pl
+++ b/util/check-format.pl
@@ -886,7 +886,8 @@ while (<>) { # loop over all lines of all input files
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 '$3'")
- if (m/(['"]|([\+\-\*\/\/%\&\|\^<>]\s*)?\W[0-9]+L?|NULL)\s*([\!<>=]=|[<=>][^<>])/ && $2 eq "");
+ if (m/(['"]|([\+\-\*\/\/%\&\|\^<>]\s*)?\W[0-9]+L?|\WNULL)\s*([\!<>=]=|[<=>])([<>]?)/ &&
+ $2 eq "" && (($3 ne "<" && $3 ne "='" && $3 ne ">") || $4 eq ""));
# TODO report #if 0 and #if 1