summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-12-26 21:57:23 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2025-01-05 22:16:08 +0000
commit12036e1ff02d0c02d0f69050c1f080e8ca947cd5 (patch)
treee2d904e4c231c425df0f1e01e54046e60d597562 /apt-pkg
parent3977dd98d30e40986f883fe03370d673eb616442 (diff)
Drop usage of APT_MUSTCHECK
nodiscard is a C++17 feature and already used (not just due to my recent changes) in our codebase, so lets drop the last remaining holdouts.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc4
-rw-r--r--apt-pkg/contrib/macros.h4
-rw-r--r--apt-pkg/contrib/strutl.h4
-rw-r--r--apt-pkg/packagemanager.h14
-rw-r--r--apt-pkg/tagfile.h2
5 files changed, 14 insertions, 14 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index a72766e8d..e57662abc 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1070,7 +1070,7 @@ struct APT_HIDDEN simple_buffer { /*{{{*/
reset();
}
void reset() { bufferend = bufferstart = 0; }
- ssize_t read(void *to, unsigned long long requested_size) APT_MUSTCHECK
+ [[nodiscard]] ssize_t read(void *to, unsigned long long requested_size)
{
if (size() < requested_size)
requested_size = size();
@@ -1080,7 +1080,7 @@ struct APT_HIDDEN simple_buffer { /*{{{*/
bufferstart = bufferend = 0;
return requested_size;
}
- ssize_t write(const void *from, unsigned long long requested_size) APT_MUSTCHECK
+ [[nodiscard]] ssize_t write(const void *from, unsigned long long requested_size)
{
if (free() < requested_size)
requested_size = free();
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index eeac81d31..7d8a9e2b2 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -48,10 +48,8 @@
#if APT_GCC_VERSION > 0x0302
#define APT_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
- #define APT_MUSTCHECK __attribute__((warn_unused_result))
#else
#define APT_NONNULL(...)
- #define APT_MUSTCHECK
#endif
#if APT_GCC_VERSION >= 0x0400
@@ -133,11 +131,13 @@ AptScopeWrapper(F) -> AptScopeWrapper<F>;
#define APT_DEPRECATED_MSG(X) __attribute__ ((deprecated(X)))
#define APT_NORETURN __attribute__((noreturn))
#define APT_UNUSED __attribute__((unused))
+ #define APT_MUSTCHECK __attribute__((warn_unused_result))
#else
#define APT_DEPRECATED
#define APT_DEPRECATED_MSG(X)
#define APT_NORETURN
#define APT_UNUSED
+ #define APT_MUSTCHECK
#endif
#endif
#endif
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index ecb61000d..6f80155e8 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -97,8 +97,8 @@ APT_PUBLIC std::string TimeRFC1123(time_t Date, bool const NumericTimezone);
* parsing is successful, undefined otherwise.
* @return \b true if parsing was successful, otherwise \b false.
*/
-APT_PUBLIC bool RFC1123StrToTime(const std::string &str,time_t &time) APT_MUSTCHECK;
-APT_PUBLIC bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
+[[nodiscard]] APT_PUBLIC bool RFC1123StrToTime(const std::string &str,time_t &time);
+[[nodiscard]] APT_PUBLIC bool FTPMDTMStrToTime(const char* const str,time_t &time);
APT_PUBLIC std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0);
APT_PUBLIC int StringToBool(const std::string &Text,int Default = -1);
APT_PUBLIC bool ReadMessages(int Fd, std::vector<std::string> &List);
diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h
index d4cc3c63c..559bbe0c9 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -78,10 +78,10 @@ class APT_PUBLIC pkgPackageManager : protected pkgCache::Namespace
// Install helpers
bool ConfigureAll();
- bool SmartConfigure(PkgIterator Pkg, int const Depth) APT_MUSTCHECK;
- bool SmartUnPack(PkgIterator Pkg, bool const Immediate = true, int const Depth = 0) APT_MUSTCHECK;
- bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK;
- bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK;
+ [[nodiscard]] bool SmartConfigure(PkgIterator Pkg, int Depth);
+ [[nodiscard]] bool SmartUnPack(PkgIterator Pkg, bool Immediate = true, int Depth = 0);
+ [[nodiscard]] bool SmartRemove(PkgIterator Pkg);
+ [[nodiscard]] bool EarlyRemove(PkgIterator Pkg, DepIterator const *Dep);
// The Actual installation implementation
virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
@@ -130,9 +130,9 @@ class APT_PUBLIC pkgPackageManager : protected pkgCache::Namespace
private:
void * const d;
enum APT_HIDDEN SmartAction { UNPACK_IMMEDIATE, UNPACK, CONFIGURE };
- APT_HIDDEN bool NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
- pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
- bool * const Bad, bool * const Changed) APT_MUSTCHECK;
+ [[nodiscard]] APT_HIDDEN bool NonLoopingSmart(SmartAction action, pkgCache::PkgIterator &Pkg,
+ pkgCache::PkgIterator DepPkg, int Depth, bool PkgLoop,
+ bool *Bad, bool *Changed);
};
#endif
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index b32317cec..cf012eb8b 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -120,7 +120,7 @@ class APT_PUBLIC pkgTagSection
* @return \b true if section end was found, \b false otherwise.
* Beware that internal state will be inconsistent if \b false is returned!
*/
- APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength, bool const Restart = true);
+ [[nodiscard]] bool Scan(const char *Start, unsigned long MaxLength, bool const Restart = true);
inline unsigned long size() const {return Stop - Section;};
void Trim();