mirror of https://github.com/openssl/openssl.git
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)
This commit is contained in:
parent
f14bead2c4
commit
ff38103324
|
@ -150,6 +150,10 @@ int f(void) /*
|
|||
hanging_stmt;
|
||||
}
|
||||
|
||||
/* should not trigger: constant on LHS of comparison or assignment operator */
|
||||
X509 *x509 = NULL;
|
||||
int y = a + 1 < b;
|
||||
|
||||
const OPTIONS passwd_options[] = {
|
||||
{"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
|
||||
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
|
|
|
@ -75,7 +75,8 @@ int f (int a, /*@ space after fn before '(', reported unless sloppy-spc */
|
|||
long l) /*@ one-letter name 'l' */
|
||||
{ int /*@ code after '{' opening a block */
|
||||
xx = 1) + /*@ unexpected closing parenthesis */
|
||||
2] - /*@ unexpected closing bracket */
|
||||
0L < /*@ constant on LHS of comparison operator */
|
||||
a] - /*@ unexpected closing bracket */
|
||||
3: * /*@ unexpected ':' (without preceding '?') within expr */
|
||||
4}; /*@ unexpected closing brace within expression */
|
||||
char y[] = { /*@0 unclosed brace within initializer/enum expression */
|
||||
|
@ -91,7 +92,7 @@ int f (int a, /*@ space after fn before '(', reported unless sloppy-spc */
|
|||
b, /*@ expr indent as on line above, accepted if sloppy-hang */
|
||||
b, /*@ expr indent off -8 but @ extra indent accepted if sloppy-hang */
|
||||
"again aligned" /*@ expr indent off by -9 (left of stmt indent, */ "right",
|
||||
123 == /*@ .. so reported also with sloppy-hang; this line is too long */ 456
|
||||
abc == /*@ .. so reported also with sloppy-hang; this line is too long */ 456
|
||||
# define MAC(A) (A) /*@ nesting indent of preprocessor directive off by 1 */
|
||||
? 1 /*@ hanging expr indent off by 1 */
|
||||
: 2); /*@ hanging expr indent off by 2, or 1 for leading ':' */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue