Skip to content

Commit 11772cc

Browse files
committed
mitigated readability-redundant-parentheses clang-tidy warnings
1 parent cac0c8b commit 11772cc

12 files changed

Lines changed: 25 additions & 25 deletions

cli/signalhandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
238238
}
239239
fprintf(output, " (at 0x%lx).%s\n",
240240
reinterpret_cast<unsigned long>(info->si_addr),
241-
(isAddressOnStack)?" Stackoverflow?":"");
241+
isAddressOnStack ? " Stackoverflow?" : "");
242242
break;
243243
case SIGINT:
244244
unexpectedSignal=false; // legal usage: interrupt application via CTRL-C
@@ -264,7 +264,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
264264
(type==-1)? "" :
265265
(type==0) ? "reading " : "writing ",
266266
reinterpret_cast<unsigned long>(info->si_addr),
267-
(isAddressOnStack)?" Stackoverflow?":""
267+
isAddressOnStack ? " Stackoverflow?" : ""
268268
);
269269
break;
270270
case SIGUSR1:

lib/checkautovariables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void CheckAutoVariables::autoVariables()
308308
for (const ValueFlow::Value &v : tok->values()) {
309309
if (v.isImpossible())
310310
continue;
311-
if ((v.isTokValue() && (isArrayVar(v.tokvalue) || ((v.tokvalue->tokType() == Token::eString)))) ||
311+
if ((v.isTokValue() && (isArrayVar(v.tokvalue) || (v.tokvalue->tokType() == Token::eString))) ||
312312
(v.isLocalLifetimeValue() && v.lifetimeKind == ValueFlow::Value::LifetimeKind::Address && !Token::simpleMatch(v.tokvalue, "("))) {
313313
errorInvalidDeallocation(tok, &v);
314314
break;

lib/checkclass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,9 +3182,9 @@ enum class CtorType : std::uint8_t {
31823182

31833183
void CheckClass::checkCopyCtorAndEqOperator()
31843184
{
3185-
// This is disabled because of #8388
3185+
// TODO: This is disabled because of #8388
31863186
// The message must be clarified. How is the behaviour different?
3187-
if ((true) || !mSettings->severity.isEnabled(Severity::warning)) // NOLINT(readability-simplify-boolean-expr)
3187+
if ((true) || !mSettings->severity.isEnabled(Severity::warning)) // NOLINT(readability-simplify-boolean-expr,readability-redundant-parentheses)
31883188
return;
31893189

31903190
// logChecker

lib/checkcondition.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ static bool parseComparison(const Token *comp, bool &not1, std::string &op, std:
10591059
{
10601060
not1 = false;
10611061
while (comp && comp->str() == "!") {
1062-
not1 = !(not1);
1062+
not1 = !not1;
10631063
comp = comp->astOperand1();
10641064
}
10651065

@@ -1096,7 +1096,7 @@ static bool parseComparison(const Token *comp, bool &not1, std::string &op, std:
10961096
expr = comp;
10971097
}
10981098

1099-
inconclusive = inconclusive || ((value)[0] == '\'' && !(op == "!=" || op == "=="));
1099+
inconclusive = inconclusive || (value[0] == '\'' && !(op == "!=" || op == "=="));
11001100

11011101
// Only float and int values are currently handled
11021102
return MathLib::isInt(value) || MathLib::isFloat(value) || (value[0] == '\'');
@@ -1288,13 +1288,13 @@ void CheckCondition::checkIncorrectLogicOperator()
12881288
continue;
12891289

12901290
// the expr are not the token of the value but they provide better context
1291-
const double d1 = (isfloat) ? MathLib::toDoubleNumber(value1) : 0;
1292-
const double d2 = (isfloat) ? MathLib::toDoubleNumber(value2) : 0;
1293-
const MathLib::bigint i1 = (isfloat) ? 0 : MathLib::toBigNumber(value1, expr1);
1294-
const MathLib::bigint i2 = (isfloat) ? 0 : MathLib::toBigNumber(value2, expr2);
1291+
const double d1 = isfloat ? MathLib::toDoubleNumber(value1) : 0;
1292+
const double d2 = isfloat ? MathLib::toDoubleNumber(value2) : 0;
1293+
const MathLib::bigint i1 = isfloat ? 0 : MathLib::toBigNumber(value1, expr1);
1294+
const MathLib::bigint i2 = isfloat ? 0 : MathLib::toBigNumber(value2, expr2);
12951295
const bool useUnsignedInt = (std::numeric_limits<MathLib::bigint>::max()==i1) || (std::numeric_limits<MathLib::bigint>::max()==i2);
1296-
const MathLib::biguint u1 = (useUnsignedInt) ? MathLib::toBigUNumber(value1, expr1) : 0;
1297-
const MathLib::biguint u2 = (useUnsignedInt) ? MathLib::toBigUNumber(value2, expr2) : 0;
1296+
const MathLib::biguint u1 = useUnsignedInt ? MathLib::toBigUNumber(value1, expr1) : 0;
1297+
const MathLib::biguint u2 = useUnsignedInt ? MathLib::toBigUNumber(value2, expr2) : 0;
12981298
// evaluate if expression is always true/false
12991299
bool alwaysTrue = true, alwaysFalse = true;
13001300
bool firstTrue = true, secondTrue = true;

lib/checkio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ bool CheckIO::ArgumentInfo::isArrayOrPointer() const
16811681
bool CheckIO::ArgumentInfo::isComplexType() const
16821682
{
16831683
if (variableInfo->type())
1684-
return (true);
1684+
return true;
16851685

16861686
const Token* varTypeTok = typeToken;
16871687
if (varTypeTok->str() == "std")

lib/checkmemoryleak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void CheckMemoryLeakInFunction::checkReallocUsage()
454454
continue;
455455

456456
const AllocType allocType = getReallocationType(reallocTok, tok->varId());
457-
if (!((allocType == Malloc || allocType == OtherMem)))
457+
if (!(allocType == Malloc || allocType == OtherMem))
458458
continue;
459459
const Token* arg = getArguments(reallocTok).at(f->reallocArg - 1);
460460
while (arg && arg->isCast())

lib/checkother.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,8 +1468,8 @@ void CheckOther::variableScopeError(const Token *tok, const std::string &varname
14681468
//---------------------------------------------------------------------------
14691469
void CheckOther::checkCommaSeparatedReturn()
14701470
{
1471-
// This is experimental for now. See #5076
1472-
if ((true) || !mSettings->severity.isEnabled(Severity::style)) // NOLINT(readability-simplify-boolean-expr)
1471+
// TODO: This is experimental for now. See #5076
1472+
if ((true) || !mSettings->severity.isEnabled(Severity::style)) // NOLINT(readability-simplify-boolean-expr,readability-redundant-parentheses)
14731473
return;
14741474

14751475
// logChecker

lib/checkuninitvar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ bool CheckUninitVar::isMemberVariableUsage(const Token *tok, bool isPointer, All
15401540
return true;
15411541

15421542
// TODO: this used to be experimental - enable or remove see #5586
1543-
if ((false) && // NOLINT(readability-simplify-boolean-expr)
1543+
if ((false) && // NOLINT(readability-simplify-boolean-expr,readability-redundant-parentheses)
15441544
!isPointer &&
15451545
Token::Match(tok->tokAt(-2), "[(,] & %name% [,)]") &&
15461546
isVariableUsage(tok, isPointer, alloc))

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
19421942
// function returning function pointer? '... ( ... %name% ( ... ))( ... ) {'
19431943
// function returning reference to array '... ( & %name% ( ... ))[ ... ] {'
19441944
// TODO: Activate this again
1945-
if ((false) && tok->str() == "(" && tok->strAt(1) != "*" && // NOLINT(readability-simplify-boolean-expr)
1945+
if ((false) && tok->str() == "(" && tok->strAt(1) != "*" && // NOLINT(readability-simplify-boolean-expr,readability-redundant-parentheses)
19461946
(tok->link()->strAt(-1) == ")" || Token::simpleMatch(tok->link()->tokAt(-2), ") const"))) {
19471947
const Token* tok2 = tok->link()->next();
19481948
if (tok2 && tok2->str() == "(" && Token::Match(tok2->link()->next(), "{|;|const|=")) {

lib/templatesimplifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,9 +2854,9 @@ bool TemplateSimplifier::simplifyCalculations(Token* frontToken, const Token *ba
28542854
} else if ((((Token::Match(tok->previous(), "[=[(,] 0 * %name%|%num% ,|]|)|;|=|%cop%") ||
28552855
Token::Match(tok->previous(), "return|case 0 *|&& %name%|%num% ,|:|;|=|%cop%")) &&
28562856
validTokenEnd(bounded, tok, backToken, 3)) ||
2857-
(((Token::Match(tok->previous(), "[=[(,] 0 * (") ||
2857+
((Token::Match(tok->previous(), "[=[(,] 0 * (") ||
28582858
Token::Match(tok->previous(), "return|case 0 *|&& (")) &&
2859-
validTokenEnd(bounded, tok, backToken, 2))))) {
2859+
validTokenEnd(bounded, tok, backToken, 2)))) {
28602860
tok->deleteNext();
28612861
if (tok->strAt(1) == "(")
28622862
eraseTokens(tok, tok->linkAt(1));

0 commit comments

Comments
 (0)