From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- apt-pkg/cacheset.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'apt-pkg/cacheset.cc') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 6b6fdb5ad..8a30d00a2 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -588,13 +588,13 @@ pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache, } /*}}}*/ // canNotFindTask - handle the case no package is found for a task /*{{{*/ -void CacheSetHelper::canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) { +void CacheSetHelper::canNotFindTask(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) { if (ShowError == true) _error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str()); } /*}}}*/ // canNotFindRegEx - handle the case no package is found by a regex /*{{{*/ -void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) { +void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) { if (ShowError == true) _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str()); } @@ -606,25 +606,25 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk } #endif /*}}}*/ // canNotFindPackage - handle the case no package is found from a string/*{{{*/ -void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) { +void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) { } /*}}}*/ // canNotFindAllVer /*{{{*/ -void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, +void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str()); } /*}}}*/ // canNotFindInstCandVer /*{{{*/ -void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, +void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); } /*}}}*/ // canNotFindInstCandVer /*{{{*/ -void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, +void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); @@ -655,13 +655,13 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache } /*}}}*/ // showTaskSelection /*{{{*/ -void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &pkg, - std::string const &pattern) { +void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/, + std::string const &/*pattern*/) { } /*}}}*/ // showRegExSelection /*{{{*/ -void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg, - std::string const &pattern) { +void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/, + std::string const &/*pattern*/) { } /*}}}*/ #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) @@ -672,10 +672,10 @@ void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, /*}}}*/ #endif // showSelectedVersion /*{{{*/ -void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg, - pkgCache::VerIterator const Ver, - std::string const &ver, - bool const verIsRel) { +void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, + pkgCache::VerIterator const /*Ver*/, + std::string const &/*ver*/, + bool const /*verIsRel*/) { } /*}}}*/ } -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- apt-pkg/cacheset.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'apt-pkg/cacheset.cc') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 8a30d00a2..a58631d5b 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -16,14 +16,22 @@ #include #include #include -#include #include #include #include - -#include - +#include +#include +#include +#include +#include + +#include +#include +#include #include +#include +#include +#include #include /*}}}*/ -- cgit v1.2.3 From a02db58fd50ef7fc2f0284852c6b3f98e458a232 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Mar 2014 00:33:10 +0100 Subject: follow method attribute suggestions by gcc Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn} --- apt-pkg/cacheset.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-pkg/cacheset.cc') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index a58631d5b..d453a2bfb 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -614,7 +614,7 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk } #endif /*}}}*/ // canNotFindPackage - handle the case no package is found from a string/*{{{*/ -void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) { +APT_CONST void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) { } /*}}}*/ // canNotFindAllVer /*{{{*/ @@ -663,24 +663,24 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache } /*}}}*/ // showTaskSelection /*{{{*/ -void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/, +APT_CONST void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/, std::string const &/*pattern*/) { } /*}}}*/ // showRegExSelection /*{{{*/ -void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/, +APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/, std::string const &/*pattern*/) { } /*}}}*/ #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) // showFnmatchSelection /*{{{*/ -void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, +APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern) { } /*}}}*/ #endif // showSelectedVersion /*{{{*/ -void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, +APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, pkgCache::VerIterator const /*Ver*/, std::string const &/*ver*/, bool const /*verIsRel*/) { -- cgit v1.2.3 From d99854cac4065bc7b337815fb2116269d58dab73 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 21 Apr 2014 13:26:55 +0200 Subject: handle pkgnames shorter than modifiers The bugreport highlights the problem with an empty package name. We fix this by 'ignoring' these so that it behaves just like "apt-get install". The deeper problem is that modifier strings can be longer than a package name in which case the comparison doesn't make sense, so don't compare then. Was not noticed so far as all modifiers are of length 1, so the only package name shorter than this is in fact the empty package name. Closes: 744940 --- apt-pkg/cacheset.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-pkg/cacheset.cc') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index d453a2bfb..2ed6a96da 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -391,6 +391,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, CacheSetHelper &helper) { Version select = NEWEST; std::string str = cmdline; + if (unlikely(str.empty() == true)) + return false; bool modifierPresent = false; unsigned short fallback = modID; for (std::list::const_iterator mod = mods.begin(); @@ -400,8 +402,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, size_t const alength = strlen(mod->Alias); switch(mod->Pos) { case Modifier::POSTFIX: - if (str.compare(str.length() - alength, alength, - mod->Alias, 0, alength) != 0) + if (str.length() <= alength || + str.compare(str.length() - alength, alength, mod->Alias, 0, alength) != 0) continue; str.erase(str.length() - alength); modID = mod->ID; -- cgit v1.2.3