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:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user