diff options
author | Brad King <brad.king@kitware.com> | 2009-09-11 12:18:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-09-11 12:18:15 (GMT) |
commit | b41a548d86f8989e790f0150abd3eb337e8c03d0 (patch) | |
tree | e22e5e910e1b5769e8bcec6fa20ac703df013e55 /Source | |
parent | e0df0495e5b313e1f017ebb938c4522db6d5b89c (diff) | |
download | CMake-b41a548d86f8989e790f0150abd3eb337e8c03d0.zip CMake-b41a548d86f8989e790f0150abd3eb337e8c03d0.tar.gz CMake-b41a548d86f8989e790f0150abd3eb337e8c03d0.tar.bz2 |
Add parentheses around '&&' between '||' for gcc
The GNU compiler warns about possible operator precedence mistakes and
asks for explicit parentheses (-Wparentheses). We add the parentheses
to silence the warning. This also fixes one real logic error in the
find_package() implementation by correcting expression evaluation order.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cpack.cxx | 9 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 8 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 20 | ||||
-rw-r--r-- | Source/cmCMakeMinimumRequired.cxx | 14 | ||||
-rw-r--r-- | Source/cmExecuteProcessCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 2 | ||||
-rw-r--r-- | Source/cmSetCommand.cxx | 6 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 12 | ||||
-rw-r--r-- | Source/cmUtilitySourceCommand.cxx | 2 |
11 files changed, 47 insertions, 42 deletions
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 51001aa..2782dca 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -359,10 +359,11 @@ int main (int argc, char *argv[]) "CPack project name not specified" << std::endl); parsed = 0; } - if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION") - || mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") && - mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") - && mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) ) + if (parsed && + !(mf->GetDefinition("CPACK_PACKAGE_VERSION") || + (mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") && + mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") && + mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project version not specified" << std::endl diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index d85df86..f998235 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -611,8 +611,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os) it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ ) { cmCTestBuildErrorWarning *cm = &(*it); - if (cm->Error && numErrorsAllowed || - !cm->Error && numWarningsAllowed) + if ((cm->Error && numErrorsAllowed) || + (!cm->Error && numWarningsAllowed)) { if (cm->Error) { @@ -681,8 +681,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os) << "</PreContext>\n" << "\t\t<PostContext>" << cmXMLSafe(cm->PostContext).Quotes(false); // is this the last warning or error, if so notify - if (cm->Error && !numErrorsAllowed || - !cm->Error && !numWarningsAllowed) + if ((cm->Error && !numErrorsAllowed) || + (!cm->Error && !numWarningsAllowed)) { os << "\nThe maximum number of reported warnings or errors has been " "reached!!!\n"; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 4d588a9..c0c409e 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -231,7 +231,8 @@ void cmCursesMainForm::RePost() { cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) + if (mit.IsAtEnd() || + (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) { continue; } @@ -259,7 +260,8 @@ void cmCursesMainForm::RePost() { cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) + if (mit.IsAtEnd() || + (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) { continue; } @@ -327,7 +329,8 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) { cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) + if (mit.IsAtEnd() || + (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) { continue; } @@ -344,7 +347,8 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) { cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) + if (mit.IsAtEnd() || + (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) { continue; } @@ -914,10 +918,10 @@ void cmCursesMainForm::HandleInput() this->SearchMode = false; } */ - else if ( key >= 'a' && key <= 'z' || - key >= 'A' && key <= 'Z' || - key >= '0' && key <= '9' || - key == '_' ) + else if ((key >= 'a' && key <= 'z') || + (key >= 'A' && key <= 'Z') || + (key >= '0' && key <= '9') || + (key == '_' )) { if ( this->SearchString.size() < static_cast<std::string::size_type>(x-10) ) { diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 49860c5..f3fad85 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -87,12 +87,12 @@ bool cmCMakeMinimumRequired } // Compare the version numbers. - if(current_major < required_major || - current_major == required_major && - current_minor < required_minor || - current_major == required_major && - current_minor == required_minor && - current_patch < required_patch) + if((current_major < required_major) || + (current_major == required_major && + current_minor < required_minor) || + (current_major == required_major && + current_minor == required_minor && + current_patch < required_patch)) { // The current version is too low. cmOStringStream e; @@ -110,7 +110,7 @@ bool cmCMakeMinimumRequired return false; } - if (required_major < 2 || required_major == 2 && required_minor < 4) + if (required_major < 2 || (required_major == 2 && required_minor < 4)) { this->Makefile->SetPolicyVersion("2.4"); } diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 3b09e48..28ad80d 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -298,8 +298,8 @@ bool cmExecuteProcessCommand while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) { // Put the output in the right place. - if(p == cmsysProcess_Pipe_STDOUT && !output_quiet || - p == cmsysProcess_Pipe_STDERR && !error_quiet && merge_output) + if((p == cmsysProcess_Pipe_STDOUT && !output_quiet) || + (p == cmsysProcess_Pipe_STDERR && !error_quiet && merge_output)) { if(output_variable.empty()) { diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index f9a7dfc..47e098f 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -590,7 +590,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) { // Ignore CR character to make output always have UNIX newlines. } - else if(c >= 0x20 && c < 0x7F || c == '\t' || c == '\f' || + else if((c >= 0x20 && c < 0x7F) || c == '\t' || c == '\f' || (c == '\n' && newline_consume)) { // This is an ASCII character that may be part of a string. @@ -1973,7 +1973,7 @@ bool cmFileInstaller::HandleInstallDestination() if ( ch1 != '/' ) { int relative = 0; - if ( ( ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z' ) && + if (((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z')) && ch2 == ':' ) { // Assume windows diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9ac73f8..ff1d94c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -900,13 +900,13 @@ void cmFindPackageCommand::FindConfig() bool found = false; // Search for frameworks. - if(!found && this->SearchFrameworkFirst || this->SearchFrameworkOnly) + if(!found && (this->SearchFrameworkFirst || this->SearchFrameworkOnly)) { found = this->FindFrameworkConfig(); } // Search for apps. - if(!found && this->SearchAppBundleFirst || this->SearchAppBundleOnly) + if(!found && (this->SearchAppBundleFirst || this->SearchAppBundleOnly)) { found = this->FindAppBundleConfig(); } @@ -1136,8 +1136,8 @@ void cmFindPackageCommand::AddPrefixesSystemEnvironment() std::string const& d = *i; // If the path is a PREFIX/bin case then add its parent instead. - if(d.size() >= 4 && strcmp(d.c_str()+d.size()-4, "/bin") == 0 || - d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0) + if((d.size() >= 4 && strcmp(d.c_str()+d.size()-4, "/bin") == 0) || + (d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0)) { this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath); } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 95bf972..ea8726e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -497,7 +497,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, } // it is an error if the policy version is less than 2.4 - if (majorVer < 2 || majorVer == 2 && minorVer < 4) + if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) { mf->IssueMessage(cmake::FATAL_ERROR, "An attempt was made to set the policy version of CMake to something " diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index e2714b6..4b361b0 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -134,9 +134,9 @@ bool cmSetCommand // we should be nice and try to catch some simple screwups if the last or // next to last args are CACHE then they screwed up. If they used FORCE // without CACHE they screwed up - if (args[args.size() - 1] == "CACHE" || - args.size() > 1 && args[args.size() - 2] == "CACHE" || - force && !cache) + if ((args[args.size() - 1] == "CACHE") || + (args.size() > 1 && args[args.size() - 2] == "CACHE") || + (force && !cache)) { this->SetError("given invalid arguments for CACHE mode."); return false; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index d0ed2d6..8a9c06e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -510,12 +510,12 @@ std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command) bool win_path = false; - if ( command[0] != '/' && command[1] == ':' && command[2] == '\\' || - command[0] == '\"' && command[1] != '/' && command[2] == ':' - && command[3] == '\\' || - command[0] == '\'' && command[1] != '/' && command[2] == ':' - && command[3] == '\\' || - command[0] == '\\' && command[1] == '\\') + if ((command[0] != '/' && command[1] == ':' && command[2] == '\\') || + (command[0] == '\"' && command[1] != '/' && command[2] == ':' + && command[3] == '\\') || + (command[0] == '\'' && command[1] != '/' && command[2] == ':' + && command[3] == '\\') || + (command[0] == '\\' && command[1] == '\\')) { win_path = true; } diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index f8683ce..929696f 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -56,7 +56,7 @@ bool cmUtilitySourceCommand { haveCacheValue = (cacheValue && (strstr(cacheValue, "(IntDir)") == 0 || - intDir && strcmp(intDir, "$(IntDir)") == 0) && + (intDir && strcmp(intDir, "$(IntDir)") == 0)) && (this->Makefile->GetCacheMajorVersion() != 0 && this->Makefile->GetCacheMinorVersion() != 0 )); } |