Fix left-over occurrences of else-after-return

Fix issues diagnosed by clang-tidy [readability-else-after-return]

These were mostly only showing up on OSX.

Signed-off-by: Matthias Maennich <matthias@maennich.net>
This commit is contained in:
Matthias Maennich
2017-09-19 16:19:31 +02:00
committed by Brad King
parent 2033abff0d
commit 870dd06da1
5 changed files with 32 additions and 33 deletions

View File

@@ -226,14 +226,14 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary); cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
if (!fout) { if (!fout) {
return false; return false;
} else {
// Seek to desired size - 1 byte
fout.seekp(size - 1, std::ios::beg);
char byte = 0;
// Write one byte to ensure file grows
fout.write(&byte, 1);
} }
// Seek to desired size - 1 byte
fout.seekp(size - 1, std::ios::beg);
char byte = 0;
// Write one byte to ensure file grows
fout.write(&byte, 1);
return true; return true;
} }

View File

@@ -42,9 +42,9 @@ std::string cmCPackPKGGenerator::GetPackageName(
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< component.Name << ".pkg"; << component.Name << ".pkg";
return out.str(); return out.str();
} else {
return component.ArchiveFile + ".pkg";
} }
return component.ArchiveFile + ".pkg";
} }
void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)

View File

@@ -2294,10 +2294,9 @@ bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args)
if (errorArg.GetString().empty()) { if (errorArg.GetString().empty()) {
this->SetError(error); this->SetError(error);
return false; return false;
} else {
this->Makefile->AddDefinition(errorArg.GetString(), error.c_str());
return true;
} }
this->Makefile->AddDefinition(errorArg.GetString(), error.c_str());
return true;
#endif #endif
} }

View File

@@ -116,18 +116,22 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
// Compare using nanosecond resolution. // Compare using nanosecond resolution.
if (s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec) { if (s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec) {
return -1; return -1;
} else if (s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec) { }
if (s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec) {
return 1; return 1;
} else if (s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec) { }
if (s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec) {
return -1; return -1;
} else if (s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec) { }
if (s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec) {
return 1; return 1;
} }
#else #else
// Compare using 1 second resolution. // Compare using 1 second resolution.
if (s1->st_mtime < s2->st_mtime) { if (s1->st_mtime < s2->st_mtime) {
return -1; return -1;
} else if (s1->st_mtime > s2->st_mtime) { }
if (s1->st_mtime > s2->st_mtime) {
return 1; return 1;
} }
#endif #endif
@@ -162,20 +166,20 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec; long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec;
if (t1 < t2) { if (t1 < t2) {
return (t2 - t1) >= bil; return (t2 - t1) >= bil;
} else if (t2 < t1) {
return (t1 - t2) >= bil;
} else {
return false;
} }
if (t2 < t1) {
return (t1 - t2) >= bil;
}
return false;
#else #else
// Times are integers in units of 1s. // Times are integers in units of 1s.
if (s1->st_mtime < s2->st_mtime) { if (s1->st_mtime < s2->st_mtime) {
return (s2->st_mtime - s1->st_mtime) >= 1; return (s2->st_mtime - s1->st_mtime) >= 1;
} else if (s1->st_mtime > s2->st_mtime) {
return (s1->st_mtime - s2->st_mtime) >= 1;
} else {
return false;
} }
if (s1->st_mtime > s2->st_mtime) {
return (s1->st_mtime - s2->st_mtime) >= 1;
}
return false;
#endif #endif
#else #else
// Times are integers in units of 100ns. // Times are integers in units of 100ns.

View File

@@ -111,9 +111,8 @@ public:
{ {
if (this->Group) { if (this->Group) {
return this->Group; return this->Group;
} else {
return this->Generator->CreateString(this->String);
} }
return this->Generator->CreateString(this->String);
} }
}; };
@@ -240,10 +239,9 @@ std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
makeProgram = "xcodebuild"; makeProgram = "xcodebuild";
} }
return makeProgram; return makeProgram;
} else {
// Use cmakexbuild wrapper to suppress environment dump from output.
return cmSystemTools::GetCMakeCommand() + "xbuild";
} }
// Use cmakexbuild wrapper to suppress environment dump from output.
return cmSystemTools::GetCMakeCommand() + "xbuild";
} }
bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts, bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
@@ -2355,9 +2353,8 @@ const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
(target->GetType() == cmStateEnums::STATIC_LIBRARY || (target->GetType() == cmStateEnums::STATIC_LIBRARY ||
target->GetType() == cmStateEnums::OBJECT_LIBRARY)) { target->GetType() == cmStateEnums::OBJECT_LIBRARY)) {
return "OTHER_LIBTOOLFLAGS"; return "OTHER_LIBTOOLFLAGS";
} else {
return "OTHER_LDFLAGS";
} }
return "OTHER_LDFLAGS";
} }
const char* cmGlobalXCodeGenerator::GetTargetFileType( const char* cmGlobalXCodeGenerator::GetTargetFileType(
@@ -2376,10 +2373,9 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
case cmStateEnums::MODULE_LIBRARY: case cmStateEnums::MODULE_LIBRARY:
if (target->IsXCTestOnApple()) if (target->IsXCTestOnApple())
return "wrapper.cfbundle"; return "wrapper.cfbundle";
else if (target->IsCFBundleOnApple()) if (target->IsCFBundleOnApple())
return "wrapper.plug-in"; return "wrapper.plug-in";
else return "compiled.mach-o.executable";
return "compiled.mach-o.executable";
case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::SHARED_LIBRARY:
return (target->GetPropertyAsBool("FRAMEWORK") return (target->GetPropertyAsBool("FRAMEWORK")
? "wrapper.framework" ? "wrapper.framework"