From fa19a9ddbdddeaed44480ce7dade11d526336435 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 11 Sep 2024 16:57:04 +0000 Subject: Acknowledge non-erase usage of remove_if for volatile sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- apt-pkg/sourcelist.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') 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 * 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)) -- cgit v1.2.3-70-g09d2 From 8c760266c8c736bff62055c008ab74d78f3ed82a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 19 Nov 2024 22:42:44 +0000 Subject: Tag hidden acquire classes as final for devirtualization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc reports `warning: Declaring type ‘class X’ final would enable devirtualization of Y calls [-Wsuggest-final-types]`. Not that this would massively improve performance, but it shouldn't hurt telling the compiler what is obvious for a human. --- apt-pkg/acquire-item.cc | 4 ++-- apt-pkg/acquire-item.h | 12 ++++++------ methods/connect.cc | 4 ++-- methods/copy.cc | 2 +- methods/file.cc | 2 +- methods/http.cc | 2 +- methods/http.h | 4 ++-- methods/rred.cc | 2 +- methods/store.cc | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 12292eb28..73e9940ee 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -717,7 +717,7 @@ bool pkgAcqIndexDiffs::AcquireByHash() const } /*}}}*/ -class APT_HIDDEN NoActionItem : public pkgAcquire::Item /*{{{*/ +class APT_HIDDEN NoActionItem final : public pkgAcquire::Item /*{{{*/ /* The sole purpose of this class is having an item which does nothing to reach its done state to prevent cleanup deleting the mentioned file. Handy in cases in which we know we have the file already, like IMS-Hits. */ @@ -741,7 +741,7 @@ class APT_HIDDEN NoActionItem : public pkgAcquire::Item /*{{{*/ } }; /*}}}*/ -class APT_HIDDEN CleanupItem : public pkgAcqTransactionItem /*{{{*/ +class APT_HIDDEN CleanupItem final : public pkgAcqTransactionItem /*{{{*/ /* This class ensures that a file which was configured but isn't downloaded for various reasons isn't kept in an old version in the lists directory. In a way its the reverse of NoActionItem as it helps with removing files diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 22da9815d..cfea61cf6 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -530,7 +530,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase * * \sa pkgAcqMetaIndex */ -class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem +class APT_HIDDEN pkgAcqMetaSig final : public pkgAcqTransactionItem { void * const d; @@ -560,7 +560,7 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem }; /*}}}*/ /** \brief An item responsible for downloading clearsigned metaindexes {{{*/ -class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex +class APT_HIDDEN pkgAcqMetaClearSig final : public pkgAcqMetaIndex { void * const d; IndexTarget const DetachedDataTarget; @@ -707,7 +707,7 @@ struct APT_HIDDEN DiffInfo { /*{{{*/ * * \sa pkgAcqIndexDiffs, pkgAcqIndex */ -class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex +class APT_HIDDEN pkgAcqDiffIndex final : public pkgAcqIndex { void * const d; std::vector * diffs; @@ -773,7 +773,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex * * \sa pkgAcqDiffIndex, pkgAcqIndex */ -class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex +class APT_HIDDEN pkgAcqIndexMergeDiffs final : public pkgAcqBaseIndex { protected: @@ -848,7 +848,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * * \sa pkgAcqDiffIndex, pkgAcqIndex */ -class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex +class APT_HIDDEN pkgAcqIndexDiffs final : public pkgAcqBaseIndex { private: @@ -1194,7 +1194,7 @@ class APT_PUBLIC pkgAcqFile : public pkgAcquire::Item virtual ~pkgAcqFile(); }; /*}}}*/ -class APT_HIDDEN pkgAcqAuxFile : public pkgAcqFile /*{{{*/ +class APT_HIDDEN pkgAcqAuxFile final : public pkgAcqFile /*{{{*/ { pkgAcquire::Item *const Owner; pkgAcquire::Worker *const Worker; diff --git a/methods/connect.cc b/methods/connect.cc index f3e199d0a..12847c594 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -85,7 +85,7 @@ static bool ConnectionAllowed(char const * const Service, std::string const &Hos /*}}}*/ // File Descriptor based Fd /*{{{*/ -struct FdFd : public MethodFd +struct FdFd final : public MethodFd { int fd = -1; int Fd() APT_OVERRIDE { return fd; } @@ -805,7 +805,7 @@ ResultState UnwrapSocks(std::string Host, int Port, URI Proxy, std::unique_ptr UnderlyingFd; gnutls_session_t session; diff --git a/methods/copy.cc b/methods/copy.cc index 82eed150c..44205e4cd 100644 --- a/methods/copy.cc +++ b/methods/copy.cc @@ -24,7 +24,7 @@ #include /*}}}*/ -class CopyMethod : public aptMethod +class CopyMethod final : public aptMethod { virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE; diff --git a/methods/file.cc b/methods/file.cc index b2fe133f2..0a76c0c94 100644 --- a/methods/file.cc +++ b/methods/file.cc @@ -27,7 +27,7 @@ #include /*}}}*/ -class FileMethod : public aptMethod +class FileMethod final : public aptMethod { virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE; diff --git a/methods/http.cc b/methods/http.cc index 4d0e60d93..1e76a1f57 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -279,7 +279,7 @@ CircleBuf::~CircleBuf() /*{{{*/ // UnwrapHTTPConnect - Does the HTTP CONNECT handshake /*{{{*/ // --------------------------------------------------------------------- /* Performs a TLS handshake on the socket */ -struct HttpConnectFd : public MethodFd +struct HttpConnectFd final : public MethodFd { std::unique_ptr UnderlyingFd; std::string Buffer; diff --git a/methods/http.h b/methods/http.h index cae579afe..5bfcbc8a2 100644 --- a/methods/http.h +++ b/methods/http.h @@ -90,7 +90,7 @@ class CircleBuf ~CircleBuf(); }; -struct HttpServerState: public ServerState +struct HttpServerState final : public ServerState { // This is the connection itself. Output is data FROM the server CircleBuf In; @@ -121,7 +121,7 @@ struct HttpServerState: public ServerState virtual ~HttpServerState() {Close();}; }; -class HttpMethod : public BaseHttpMethod +class HttpMethod final : public BaseHttpMethod { public: virtual void SendReq(FetchItem *Itm) APT_OVERRIDE; diff --git a/methods/rred.cc b/methods/rred.cc index aeefea5a2..bef2e969e 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -598,7 +598,7 @@ class Patch { }; #ifndef APT_EXCLUDE_RRED_METHOD_CODE -class RredMethod : public aptMethod { +class RredMethod final : public aptMethod { private: bool Debug; diff --git a/methods/store.cc b/methods/store.cc index 23d6b43d0..ed2eb3fe1 100644 --- a/methods/store.cc +++ b/methods/store.cc @@ -31,7 +31,7 @@ #include /*}}}*/ -class StoreMethod : public aptMethod +class StoreMethod final : public aptMethod { virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE; -- cgit v1.2.3-70-g09d2