diff options
author | 2013-02-24 19:27:49 -0800 | |
---|---|---|
committer | 2013-03-02 08:59:13 -0800 | |
commit | c688a4d80b8283dc35e032d24086205c01a0b2c9 (patch) | |
tree | e19023be8c3365c0c566d9a6e7021f6b607b386e | |
parent | 0ce8ee0e8a9109d043697b7e3402fe12d7ee7542 (diff) | |
download | paludis-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.cc | 86 | ||||
-rw-r--r-- | paludis/fs_merger.cc | 3 | ||||
-rw-r--r-- | paludis/merger.cc | 3 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository.cc | 29 | ||||
-rw-r--r-- | paludis/resolver/required_confirmations.cc | 7 |
5 files changed, 64 insertions, 64 deletions
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc index a47a3dc07..fd33168a1 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 7d3011665..8567d1607 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 bec62573d..a1da296c0 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 2b7a16a61..a430aa369 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 66a424fb4..d8d934398 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> |