From 2988abd9390c1d6876610436883d1f7bcd405d8f Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sat, 10 Dec 2016 15:17:06 +0100 Subject: clang-tidy: apply modernize-use-bool-literals fixes --- Source/CPack/IFW/cmCPackIFWInstaller.cxx | 2 +- Source/CPack/IFW/cmCPackIFWPackage.cxx | 2 +- Source/CPack/IFW/cmCPackIFWRepository.cxx | 2 +- Source/CPack/cmCPackGenerator.h | 2 +- Source/CPack/cmCPackLog.h | 2 +- Source/CTest/cmCTestBuildHandler.cxx | 2 +- Source/CTest/cmCTestSubmitHandler.cxx | 4 ++-- Source/CursesDialog/ccmake.cxx | 6 ++---- Source/CursesDialog/cmCursesMainForm.cxx | 6 ++---- Source/CursesDialog/cmCursesWidget.cxx | 4 ++-- Source/cmCTest.cxx | 4 ++-- Source/cmCTest.h | 4 ++-- Source/cmFortranParserImpl.cxx | 10 +++++----- Source/cmGeneratorExpression.cxx | 3 ++- Source/cmGeneratorExpressionNode.cxx | 4 ++-- Source/cmGeneratorExpressionParser.cxx | 4 ++-- Source/cmGeneratorTarget.cxx | 13 +++++++------ Source/cmInstallTargetGenerator.cxx | 3 ++- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmState.cxx | 2 +- Source/cmSystemTools.cxx | 2 +- Source/cmcmd.cxx | 16 ++++++++-------- 22 files changed, 49 insertions(+), 50 deletions(-) diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index a6d443b..9ca7750 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -28,7 +28,7 @@ Generator->Logger->Log(logType, __FILE__, __LINE__, \ cmCPackLog_msg.str().c_str()); \ } \ - } while (0) + } while (false) cmCPackIFWInstaller::cmCPackIFWInstaller() : Generator(CM_NULLPTR) diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 902c85d..c868a14 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -29,7 +29,7 @@ Generator->Logger->Log(logType, __FILE__, __LINE__, \ cmCPackLog_msg.str().c_str()); \ } \ - } while (0) + } while (false) //---------------------------------------------------------- CompareStruct --- cmCPackIFWPackage::CompareStruct::CompareStruct() diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 8d50e30..cc204e8 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -23,7 +23,7 @@ Generator->Logger->Log(logType, __FILE__, __LINE__, \ cmCPackLog_msg.str().c_str()); \ } \ - } while (0) + } while (false) cmCPackIFWRepository::cmCPackIFWRepository() : Update(None) diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 10a5a36..5354fca 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -30,7 +30,7 @@ class cmMakefile; cmCPackLog_msg << msg; \ this->Logger->Log(logType, __FILE__, __LINE__, \ cmCPackLog_msg.str().c_str()); \ - } while (0) + } while (false) /** \class cmCPackGenerator * \brief A superclass of all CPack Generators diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index 419c932..a988ccc 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -14,7 +14,7 @@ std::ostringstream cmCPackLog_msg; \ cmCPackLog_msg << msg; \ (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str()); \ - } while (0) + } while (false) /** \class cmCPackLog * \brief A container for CPack generators diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index a455908..3bf54f0 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -948,7 +948,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, this->BuildOutputLogSize += length; // until there are any lines left in the buffer - while (1) { + while (true) { // Find the end of line t_BuildProcessingQueueType::iterator it; for (it = queue->begin(); it != queue->end(); ++it) { diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 0a6bc33..79c3663 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -748,7 +748,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, { if (scp_command.empty() || localprefix.empty() || files.empty() || remoteprefix.empty() || url.empty()) { - return 0; + return false; } std::vector argv; @@ -852,7 +852,7 @@ bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix, << "\tremoteprefix: " << remoteprefix << "\n" << "\tdestination: " << destination << std::endl); /* clang-format on */ - return 0; + return false; } cmCTest::SetOfStrings::const_iterator file; diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 919be4d..ff8e010 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -52,8 +52,7 @@ void onsig(int /*unused*/) initscr(); /* Initialization */ noecho(); /* Echo off */ cbreak(); /* nl- or cr not needed */ - keypad(stdscr, TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ refresh(); int x, y; getmaxyx(stdscr, y, x); @@ -128,8 +127,7 @@ int main(int argc, char const* const* argv) initscr(); /* Initialization */ noecho(); /* Echo off */ cbreak(); /* nl- or cr not needed */ - keypad(stdscr, TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ signal(SIGWINCH, onsig); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 4b5b4b1..939c736 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -576,8 +576,7 @@ int cmCursesMainForm::Configure(int noconfigure) } this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR); - keypad(stdscr, TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ if (retVal != 0 || !this->Errors.empty()) { // see if there was an error @@ -630,8 +629,7 @@ int cmCursesMainForm::Generate() int retVal = this->CMakeInstance->Generate(); this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR); - keypad(stdscr, TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ if (retVal != 0 || !this->Errors.empty()) { // see if there was an error diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx index 6c76764..a9918f7 100644 --- a/Source/CursesDialog/cmCursesWidget.cxx +++ b/Source/CursesDialog/cmCursesWidget.cxx @@ -28,9 +28,9 @@ void cmCursesWidget::Move(int x, int y, bool isNewPage) move_field(this->Field, y, x); if (isNewPage) { - set_new_page(this->Field, TRUE); + set_new_page(this->Field, true); } else { - set_new_page(this->Field, FALSE); + set_new_page(this->Field, false); } } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1527b30..dfec0fb 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1509,7 +1509,7 @@ bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files) bool cmCTest::SubmitExtraFiles(const char* cfiles) { if (!cfiles) { - return 1; + return true; } VectorOfStrings files; @@ -1518,7 +1518,7 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles) files = cmSystemTools::SplitString(cfiles, ';'); if (files.empty()) { - return 1; + return true; } return this->SubmitExtraFiles(files); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 8fc646f..4d33458 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -27,7 +27,7 @@ class cmXMLWriter; cmCTestLog_msg << msg; \ (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, \ cmCTestLog_msg.str().c_str()); \ - } while (0) + } while (false) #define cmCTestOptionalLog(ctSelf, logType, msg, suppress) \ do { \ @@ -35,7 +35,7 @@ class cmXMLWriter; cmCTestLog_msg << msg; \ (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, \ cmCTestLog_msg.str().c_str(), suppress); \ - } while (0) + } while (false) /** \class cmCTest * \brief Represents a ctest invocation. diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 23f881a..1a5e6c5 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -52,7 +52,7 @@ cmFortranParser_s::cmFortranParser_s(std::vector const& includes, , PPDefinitions(defines) , Info(info) { - this->InInterface = 0; + this->InInterface = false; this->InPPFalseBranch = 0; // Initialize the lexical scanner. @@ -83,9 +83,9 @@ bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname) cmFortran_yy_create_buffer(CM_NULLPTR, 16384, parser->Scanner); cmFortran_yy_switch_to_buffer(buffer, parser->Scanner); parser->FileStack.push(f); - return 1; + return true; } - return 0; + return false; } bool cmFortranParser_FilePop(cmFortranParser* parser) @@ -93,7 +93,7 @@ bool cmFortranParser_FilePop(cmFortranParser* parser) // Pop one file off the stack and close it. Switch the lexer back // to the next one on the stack. if (parser->FileStack.empty()) { - return 0; + return false; } cmFortranFile f = parser->FileStack.top(); parser->FileStack.pop(); @@ -101,7 +101,7 @@ bool cmFortranParser_FilePop(cmFortranParser* parser) YY_BUFFER_STATE current = cmFortranLexer_GetCurrentBuffer(parser->Scanner); cmFortran_yy_delete_buffer(current, parser->Scanner); cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner); - return 1; + return true; } int cmFortranParser_Input(cmFortranParser* parser, char* buffer, diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 1f2d2b4..e70bbfe 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -351,7 +351,8 @@ std::string cmGeneratorExpression::Preprocess(const std::string& input, return stripExportInterface(input, context, resolveRelative); } - assert(0 && "cmGeneratorExpression::Preprocess called with invalid args"); + assert(false && + "cmGeneratorExpression::Preprocess called with invalid args"); return std::string(); } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 3a41712..398f95b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1377,7 +1377,7 @@ cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt, #undef RETURN_POLICY - assert(0 && "Unreachable code. Not a valid policy"); + assert(false && "Unreachable code. Not a valid policy"); return cmPolicies::WARN; } @@ -1392,7 +1392,7 @@ cmPolicies::PolicyID policyForString(const char* policy_id) #undef RETURN_POLICY_ID - assert(0 && "Unreachable code. Not a valid policy"); + assert(false && "Unreachable code. Not a valid policy"); return cmPolicies::CMP0002; } diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 3b56416..c33349a 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -242,11 +242,11 @@ void cmGeneratorExpressionParser::ParseContent( if (this->NestingLevel == 0) { extendText(result, this->it); } else { - assert(0 && "Got unexpected syntax token."); + assert(false && "Got unexpected syntax token."); } assert(this->it != this->Tokens.end()); ++this->it; return; } - assert(0 && "Unhandled token in generator expression."); + assert(false && "Unhandled token in generator expression."); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6ee2c14..b6db0d6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3389,7 +3389,8 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, { switch (t) { case BoolType: - assert(0 && "String compatibility check function called for boolean"); + assert(false && + "String compatibility check function called for boolean"); return CM_NULLPTR; case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); @@ -3398,7 +3399,7 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } - assert(0 && "Unreachable!"); + assert(false && "Unreachable!"); return CM_NULLPTR; } @@ -3589,7 +3590,7 @@ std::string compatibilityType(CompatibleType t) case NumberMinType: return "Numeric minimum compatibility"; } - assert(0 && "Unreachable!"); + assert(false && "Unreachable!"); return ""; } @@ -3603,7 +3604,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant) case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } - assert(0 && "Unreachable!"); + assert(false && "Unreachable!"); return ""; } @@ -3713,7 +3714,7 @@ std::pair consistentProperty(const char* lhs, switch (t) { case BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); + assert(false && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); case StringType: return consistentStringProperty(lhs, rhs); @@ -3721,7 +3722,7 @@ std::pair consistentProperty(const char* lhs, case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } - assert(0 && "Unreachable!"); + assert(false && "Unreachable!"); return std::pair(false, null_ptr); } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 4dfa40f..88fcc56 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -97,7 +97,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( case cmStateEnums::INTERFACE_LIBRARY: // Not reachable. We never create a cmInstallTargetGenerator for // an INTERFACE_LIBRARY. - assert(0 && "INTERFACE_LIBRARY targets have no installable outputs."); + assert(false && + "INTERFACE_LIBRARY targets have no installable outputs."); break; case cmStateEnums::OBJECT_LIBRARY: case cmStateEnums::UTILITY: diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 6c5b2b2..0db5687 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -538,7 +538,7 @@ std::vector cmNinjaNormalTargetGenerator::ComputeLinkCmd() case cmStateEnums::EXECUTABLE: break; default: - assert(0 && "Unexpected target type"); + assert(false && "Unexpected target type"); } return std::vector(); } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 6e934e2..18d5ea1 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -58,7 +58,7 @@ const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType) case cmStateEnums::UNKNOWN_LIBRARY: return "UNKNOWN_LIBRARY"; } - assert(0 && "Unexpected target type"); + assert(false && "Unexpected target type"); return CM_NULLPTR; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 029594f..a635bf4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1664,7 +1664,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, std::vector::iterator erriter = err.begin(); cmProcessOutput processOutput; std::string strdata; - while (1) { + while (true) { // Check for a newline in stdout. for (; outiter != out.end(); ++outiter) { if ((*outiter == '\r') && ((outiter + 1) == out.end())) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index f1ce75a..5b12a75 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -169,13 +169,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) return 1; } // If error occurs we want to continue copying next files. - bool return_value = 0; + bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { if (!cmSystemTools::cmCopyFile(args[cc].c_str(), args[args.size() - 1].c_str())) { std::cerr << "Error copying file \"" << args[cc] << "\" to \"" << args[args.size() - 1] << "\".\n"; - return_value = 1; + return_value = true; } } return return_value; @@ -192,13 +192,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) return 1; } // If error occurs we want to continue copying next files. - bool return_value = 0; + bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { if (!cmSystemTools::CopyFileIfDifferent( args[cc].c_str(), args[args.size() - 1].c_str())) { std::cerr << "Error copying file (if different) from \"" << args[cc] << "\" to \"" << args[args.size() - 1] << "\".\n"; - return_value = 1; + return_value = true; } } return return_value; @@ -207,12 +207,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) // Copy directory content if (args[1] == "copy_directory" && args.size() > 3) { // If error occurs we want to continue copying next files. - bool return_value = 0; + bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { if (!cmSystemTools::CopyADirectory(args[cc], args[args.size() - 1])) { std::cerr << "Error copying directory from \"" << args[cc] << "\" to \"" << args[args.size() - 1] << "\".\n"; - return_value = 1; + return_value = true; } } return return_value; @@ -479,11 +479,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if (args[1] == "make_directory" && args.size() > 2) { // If error occurs we want to continue copying next files. - bool return_value = 0; + bool return_value = false; for (std::string::size_type cc = 2; cc < args.size(); cc++) { if (!cmSystemTools::MakeDirectory(args[cc].c_str())) { std::cerr << "Error creating directory \"" << args[cc] << "\".\n"; - return_value = 1; + return_value = true; } } return return_value; -- cgit v0.12