summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-09-11 16:57:04 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2024-11-22 12:11:13 +0000
commitfa19a9ddbdddeaed44480ce7dade11d526336435 (patch)
tree26e4358a08df89076a74ac664b569690c6baabd7
parentdcb81196776f5c31063e5f57104b4b021f37aa00 (diff)
Acknowledge non-erase usage of remove_if for volatile sources
gcc produces a length warning starting with: | warning: ignoring return value of ‘_FIter std::remove_if(_FIter, _FIter, _Predicate) [with …]’, declared with attribute ‘nodiscard’ [-Wunused-result] which is usually correct, but in the usage here we don't want to call an erase as we operate on a c-style new[] array here which contains pointers into argv and has an explicit sentinel (nullptr) – FileSize() is based on this sentinel. Casting to void silences the warning as is standard practice and hopefully indicates better that this is intended than ignoring the warning for the casual on-looker.
-rw-r--r--apt-pkg/sourcelist.cc2
-rw-r--r--apt-private/private-install.cc2
2 files changed, 2 insertions, 2 deletions
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index 65412b458..819344281 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -614,7 +614,7 @@ bool pkgSourceList::AddVolatileFile(std::string const &File)
/*}}}*/
void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector<std::string> * const VolatileCmdL)/*{{{*/
{
- std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const * const I) {
+ (void)std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const * const I) {
if (I != nullptr && (I[0] == '/' || (I[0] == '.' && (I[1] == '\0' || (I[1] == '.' && (I[2] == '\0' || I[2] == '/')) || I[1] == '/'))))
{
if (AddVolatileFile(I, VolatileCmdL))
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 57b5c0d5e..3f05cf9fb 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -986,7 +986,7 @@ std::vector<PseudoPkg> GetAllPackagesAsPseudo(pkgSourceList *const SL, CommandLi
std::vector<PseudoPkg> GetPseudoPackages(pkgSourceList *const SL, CommandLine &CmdL, bool (*Add)(pkgSourceList *const, PseudoPkg &&, std::vector<PseudoPkg> &), std::string const &pseudoArch)/*{{{*/
{
std::vector<PseudoPkg> VolatileCmdL;
- std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const *const I) {
+ (void)std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const *const I) {
return AddIfVolatile(SL, VolatileCmdL, Add, I, pseudoArch);
});
return VolatileCmdL;