Skip to content

Commit

Permalink
check-format.pl: Fix report on constant on LHS of comparison/assignment
Browse files Browse the repository at this point in the history
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from openssl#17434)
  • Loading branch information
DDvO authored and paulidale committed Jan 9, 2022
1 parent d8662f2 commit 15ae69f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions util/check-format-test-negatives.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
3 changes: 2 additions & 1 deletion util/check-format.pl
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ sub check_nested_nonblock_indents {
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
Expand Down

0 comments on commit 15ae69f

Please sign in to comment.