aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-02-24 19:27:49 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-03-02 08:59:13 -0800
commitc688a4d80b8283dc35e032d24086205c01a0b2c9 (patch)
treee19023be8c3365c0c566d9a6e7021f6b607b386e
parent0ce8ee0e8a9109d043697b7e3402fe12d7ee7542 (diff)
downloadpaludis-c688a4d80b8283dc35e032d24086205c01a0b2c9.tar.gz
paludis-c688a4d80b8283dc35e032d24086205c01a0b2c9.tar.xz
remove unexecuted statements
This reworks some idiom usage to avoid unexecutable statements. This is a code cleanup of locations flagged by the clang parser. No functionality change is intended.
-rw-r--r--paludis/environment_implementation.cc86
-rw-r--r--paludis/fs_merger.cc3
-rw-r--r--paludis/merger.cc3
-rw-r--r--paludis/repositories/e/e_repository.cc29
-rw-r--r--paludis/resolver/required_confirmations.cc7
5 files changed, 64 insertions, 64 deletions
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index a47a3dc..fd33168 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -483,6 +483,50 @@ namespace
return ! _map->find(qpn)->second.second;
}
};
+
+ void disambiguate_package_from(const PackageNamePart & p,
+ std::list<QualifiedPackageName> & qpns,
+ const EnvironmentImplementation * const env,
+ const std::shared_ptr<QPNIMap> & result)
+ {
+ using namespace std::placeholders;
+
+ const IsImportant is_important(result);
+ const IsInstalled is_installed(env);
+ const IsInUnimportantRepo is_in_unimportant_repo(result);
+
+ std::remove_copy_if(first_iterator(result->begin()),
+ first_iterator(result->end()),
+ std::front_inserter(qpns),
+ std::bind(std::logical_and<bool>(),
+ std::bind(std::not1(is_important), _1),
+ std::bind(std::not1(is_installed), _1)));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ qpns.remove_if(std::bind(is_in_unimportant_repo, _1));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ qpns.remove_if(std::bind(std::logical_and<bool>(),
+ std::bind(is_important, _1),
+ std::bind(std::not1(is_installed), _1)));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ qpns.remove_if(std::bind(std::logical_and<bool>(),
+ std::bind(std::not1(is_important), _1),
+ std::bind(is_installed, _1)));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ auto candidates(std::make_shared<Sequence<std::string> >());
+ std::transform(first_iterator(result->begin()),
+ first_iterator(result->end()),
+ candidates->back_inserter(),
+ &stringify<QualifiedPackageName>);
+ throw AmbiguousPackageNameError(stringify(p), candidates);
+ }
}
QualifiedPackageName
@@ -523,49 +567,9 @@ EnvironmentImplementation::fetch_unique_qualified_package_name(const PackageName
throw NoSuchPackageError(stringify(p));
if (result->size() > 1)
{
- using namespace std::placeholders;
-
std::list<QualifiedPackageName> qpns;
- do
- {
- const IsImportant is_important(result);
- const IsInstalled is_installed(this);
- const IsInUnimportantRepo is_in_unimportant_repo(result);
-
- std::remove_copy_if(first_iterator(result->begin()), first_iterator(result->end()),
- std::front_inserter(qpns),
- std::bind(std::logical_and<bool>(),
- std::bind(std::not1(is_important), _1),
- std::bind(std::not1(is_installed), _1)));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- qpns.remove_if(std::bind(is_in_unimportant_repo, _1));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- qpns.remove_if(std::bind(std::logical_and<bool>(),
- std::bind(is_important, _1),
- std::bind(std::not1(is_installed), _1)));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- qpns.remove_if(std::bind(std::logical_and<bool>(),
- std::bind(std::not1(is_important), _1),
- std::bind(is_installed, _1)));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- auto candidates(std::make_shared<Sequence<std::string> >());
- std::transform(first_iterator(result->begin()), first_iterator(result->end()), candidates->back_inserter(),
- &stringify<QualifiedPackageName>);
- throw AmbiguousPackageNameError(stringify(p), candidates);
- } while (false);
+ disambiguate_package_from(p, qpns, this, result);
if (! disambiguate)
{
diff --git a/paludis/fs_merger.cc b/paludis/fs_merger.cc
index 7d30116..8567d16 100644
--- a/paludis/fs_merger.cc
+++ b/paludis/fs_merger.cc
@@ -495,11 +495,10 @@ FSMerger::track_renamed_dir_recursive(const FSPath & dst)
case et_misc:
throw FSMergerError("Unexpected 'et_misc' entry found at: " + stringify(*d));
- continue;
case et_nothing:
case last_et:
- ;
+ break;
}
throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
diff --git a/paludis/merger.cc b/paludis/merger.cc
index bec6257..a1da296 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -451,11 +451,10 @@ Merger::do_ownership_fixes_recursive(const FSPath & dir)
case et_misc:
throw MergerError("Unexpected 'et_misc' entry found at: " + stringify(*d));
- continue;
case et_nothing:
case last_et:
- ;
+ break;
}
throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 2b7a16a..a430aa3 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -491,21 +491,22 @@ namespace
bool illegal(false);
try
{
- do
- {
- FSPath name_file(tree_root);
- name_file /= "profiles";
- name_file /= "repo_name";
-
- if (! name_file.stat().is_regular_file())
- break;
+ FSPath name_file(tree_root);
+ name_file /= "profiles";
+ name_file /= "repo_name";
- LineConfigFile f(name_file, { lcfo_disallow_comments, lcfo_disallow_continuations, lcfo_no_skip_blank_lines });
- if (f.begin() == f.end())
- break;
- return RepositoryName(*f.begin());
-
- } while (false);
+ if (name_file.stat().is_regular_file())
+ {
+ LineConfigFile f(name_file,
+ {
+ lcfo_disallow_comments,
+ lcfo_disallow_continuations,
+ lcfo_no_skip_blank_lines
+ });
+
+ if (f.begin() != f.end())
+ return RepositoryName(*f.begin());
+ }
}
catch (const RepositoryNameError &)
{
diff --git a/paludis/resolver/required_confirmations.cc b/paludis/resolver/required_confirmations.cc
index 66a424f..d8d9343 100644
--- a/paludis/resolver/required_confirmations.cc
+++ b/paludis/resolver/required_confirmations.cc
@@ -28,8 +28,6 @@ using namespace paludis::resolver;
const std::shared_ptr<RequiredConfirmation>
RequiredConfirmation::deserialise(Deserialisation & d)
{
- std::shared_ptr<RequiredConfirmation> result;
-
if (d.class_name() == "DowngradeConfirmation")
return DowngradeConfirmation::deserialise(d);
else if (d.class_name() == "NotBestConfirmation")
@@ -42,10 +40,9 @@ RequiredConfirmation::deserialise(Deserialisation & d)
return MaskedConfirmation::deserialise(d);
else if (d.class_name() == "ChangedChoicesConfirmation")
return ChangedChoicesConfirmation::deserialise(d);
- else
- throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
- return result;
+ throw InternalError(PALUDIS_HERE,
+ "unknown class '" + stringify(d.class_name()) + "'");
}
const std::shared_ptr<DowngradeConfirmation>