Merge topic 'clean-scanbuild-warnings'

e680d43d Fix an unused variable warning from scanbuild.
a4a1b729 Fix warnings from clang scanbuild.
This commit is contained in:
Brad King 2015-03-30 09:27:42 -04:00 committed by CMake Topic Stage
commit aa15ef8a84
7 changed files with 33 additions and 31 deletions

View File

@ -507,6 +507,11 @@ int cmCPackDebGenerator::createDeb()
//int retVal = -1; //int retVal = -1;
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retval, toplevel.c_str(), this->GeneratorVerbose, 0); &retval, toplevel.c_str(), this->GeneratorVerbose, 0);
if ( !res || retval )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running cmake -E md5sum "
<< cmd << std::endl);
}
// debian md5sums entries are like this: // debian md5sums entries are like this:
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
// thus strip the full path (with the trailing slash) // thus strip the full path (with the trailing slash)

View File

@ -1343,16 +1343,21 @@ int cmCTest::RunTest(std::vector<const char*> argv,
} }
*retVal = inst.Run(args, output); *retVal = inst.Run(args, output);
*output += oss.str(); if(output)
if ( log ) {
*output += oss.str();
}
if ( log && output)
{ {
*log << *output; *log << *output;
} }
cmSystemTools::ChangeDirectory(oldpath); cmSystemTools::ChangeDirectory(oldpath);
if(output)
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, {
"Internal cmCTest object used to run test." << std::endl cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
<< *output << std::endl); "Internal cmCTest object used to run test." << std::endl
<< *output << std::endl);
}
return cmsysProcess_State_Exited; return cmsysProcess_State_Exited;
} }
@ -1422,7 +1427,10 @@ int cmCTest::RunTest(std::vector<const char*> argv,
*retVal = cmsysProcess_GetExitException(cp); *retVal = cmsysProcess_GetExitException(cp);
std::string outerr = "\n*** Exception executing: "; std::string outerr = "\n*** Exception executing: ";
outerr += cmsysProcess_GetExceptionString(cp); outerr += cmsysProcess_GetExceptionString(cp);
*output += outerr; if(output)
{
*output += outerr;
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
<< std::flush); << std::flush);
} }
@ -1430,7 +1438,10 @@ int cmCTest::RunTest(std::vector<const char*> argv,
{ {
std::string outerr = "\n*** ERROR executing: "; std::string outerr = "\n*** ERROR executing: ";
outerr += cmsysProcess_GetErrorString(cp); outerr += cmsysProcess_GetErrorString(cp);
*output += outerr; if(output)
{
*output += outerr;
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
<< std::flush); << std::flush);
} }

View File

@ -3422,6 +3422,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// enable HTTP ERROR parsing // enable HTTP ERROR parsing
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
check_curl_result(res, "UPLOAD cannot set fail on error flag: ");
// enable uploading // enable uploading
res = ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); res = ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);

View File

@ -679,7 +679,6 @@ bool cmFindPackageCommand::HandlePackageMode()
if(cmSystemTools::IsOff(def) || !fileFound) if(cmSystemTools::IsOff(def) || !fileFound)
{ {
fileFound = this->FindConfig(); fileFound = this->FindConfig();
def = this->Makefile->GetDefinition(this->Variable);
} }
// Sanity check. // Sanity check.
@ -1598,7 +1597,6 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
if ((haveResult == false) && (this->Version.empty())) if ((haveResult == false) && (this->Version.empty()))
{ {
result = true; result = true;
haveResult = true;
} }
ConfigFileInfo configFileInfo; ConfigFileInfo configFileInfo;

View File

@ -2208,7 +2208,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
if(i==lastElement) if(i==lastElement)
{ {
// group already exists, replace its regular expression // group already exists, replace its regular expression
if ( regex ) if ( regex && sg)
{ {
// We only want to set the regular expression. If there are already // We only want to set the regular expression. If there are already
// source files in the group, we don't want to remove them. // source files in the group, we don't want to remove them.
@ -2224,7 +2224,11 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
sg = this->GetSourceGroup(currentName); sg = this->GetSourceGroup(currentName);
i = 0; // last component found i = 0; // last component found
} }
if(!sg)
{
cmSystemTools::Error("Could not create source group ");
return;
}
// build the whole source group path // build the whole source group path
const char* fullname = sg->GetFullName(); const char* fullname = sg->GetFullName();
cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();

View File

@ -25,14 +25,12 @@ bool cmSetTargetPropertiesCommand
// first collect up the list of files // first collect up the list of files
std::vector<std::string> propertyPairs; std::vector<std::string> propertyPairs;
bool doingFiles = true;
int numFiles = 0; int numFiles = 0;
std::vector<std::string>::const_iterator j; std::vector<std::string>::const_iterator j;
for(j= args.begin(); j != args.end();++j) for(j= args.begin(); j != args.end();++j)
{ {
if(*j == "PROPERTIES") if(*j == "PROPERTIES")
{ {
doingFiles = false;
// now loop through the rest of the arguments, new style // now loop through the rest of the arguments, new style
++j; ++j;
if (std::distance(j, args.end()) % 2 != 0) if (std::distance(j, args.end()) % 2 != 0)
@ -43,15 +41,9 @@ bool cmSetTargetPropertiesCommand
propertyPairs.insert(propertyPairs.end(), j, args.end()); propertyPairs.insert(propertyPairs.end(), j, args.end());
break; break;
} }
else if (doingFiles)
{
numFiles++;
}
else else
{ {
this->SetError("called with illegal arguments, maybe missing " numFiles++;
"a PROPERTIES specifier?");
return false;
} }
} }
if(propertyPairs.empty()) if(propertyPairs.empty())

View File

@ -26,14 +26,12 @@ bool cmSetTestsPropertiesCommand
// first collect up the list of files // first collect up the list of files
std::vector<std::string> propertyPairs; std::vector<std::string> propertyPairs;
bool doingFiles = true;
int numFiles = 0; int numFiles = 0;
std::vector<std::string>::const_iterator j; std::vector<std::string>::const_iterator j;
for(j= args.begin(); j != args.end();++j) for(j= args.begin(); j != args.end();++j)
{ {
if(*j == "PROPERTIES") if(*j == "PROPERTIES")
{ {
doingFiles = false;
// now loop through the rest of the arguments, new style // now loop through the rest of the arguments, new style
++j; ++j;
if (std::distance(j, args.end()) % 2 != 0) if (std::distance(j, args.end()) % 2 != 0)
@ -44,15 +42,9 @@ bool cmSetTestsPropertiesCommand
propertyPairs.insert(propertyPairs.end(), j, args.end()); propertyPairs.insert(propertyPairs.end(), j, args.end());
break; break;
} }
else if (doingFiles)
{
numFiles++;
}
else else
{ {
this->SetError("called with illegal arguments, maybe " numFiles++;
"missing a PROPERTIES specifier?");
return false;
} }
} }
if(propertyPairs.empty()) if(propertyPairs.empty())
@ -62,7 +54,6 @@ bool cmSetTestsPropertiesCommand
return false; return false;
} }
// now loop over all the targets // now loop over all the targets
int i; int i;
for(i = 0; i < numFiles; ++i) for(i = 0; i < numFiles; ++i)