2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +00:00

Use coccinelle to add braces to nested single line statement

Both clang-tidy and uncrustify chokes on statement like this:

for (...)
	if (...)
		break;

This commit uses a very simple semantic patch (below) to add braces around such
statements.

Semantic patch used:

@@
statement S;
expression E;
@@

while (...)
- if (E) S
+ { if (E) { S } }

@@
statement S;
expression E;
@@

for (...;...;...)
- if (E) S
+ { if (E) { S } }

@@
statement S;
expression E;
@@

if (...)
- if (E) S
+ { if (E) { S } }
This commit is contained in:
Ondřej Surý
2020-02-13 18:16:57 +01:00
parent c823ed4f07
commit 36c6105e4f
43 changed files with 537 additions and 273 deletions

View File

@@ -363,25 +363,27 @@ gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *token, bool eol,
}
/*NOTREACHED*/
}
if (eol != true)
if (token->type == isc_tokentype_eol ||
token->type == isc_tokentype_eof) {
unsigned long int line;
const char * what;
const char * file;
file = isc_lex_getsourcename(lex);
line = isc_lex_getsourceline(lex);
if (token->type == isc_tokentype_eol) {
line--;
what = "line";
} else
what = "file";
(*callbacks->error)(callbacks,
"dns_master_load: %s:%lu: "
"unexpected end of %s",
file, line, what);
return (ISC_R_UNEXPECTEDEND);
}
if (eol != true) {
if (token->type == isc_tokentype_eol || token->type == isc_tokentype_eof) {
{
unsigned long int line;
const char *what;
const char *file;
file = isc_lex_getsourcename(lex);
line = isc_lex_getsourceline(lex);
if (token->type == isc_tokentype_eol) {
line--;
what = "line";
}else
what = "file";
(*callbacks->error)(callbacks,
"dns_master_load: %s:%lu: "
"unexpected end of %s",
file, line, what);
return (ISC_R_UNEXPECTEDEND);
}
}
}
return (ISC_R_SUCCESS);
}