From f73593a4034d9eec0ec4466b8e173d4a4daece1f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Dec 2024 19:41:53 +0000 Subject: Drop usage of macro APT_OVERRIDE for simple override We were rather inconsistent in using it and as our public headers contain deduction guides (a c++17 feature) it seems silly to try to hide a c++11 feature in a macro, so lets stop this charade and drop the macro and while we are changing all these lines lets apply [[nodiscard]] (another c++17 feature) and other suggestions from clang-tidy and formatting for a little more consistency. --- cmdline/apt-cdrom.cc | 8 ++++---- cmdline/apt-extracttemplates.h | 8 ++++---- cmdline/apt-internal-planner.cc | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 94202d9e1..13d875366 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -44,12 +44,12 @@ protected: OpTextProgress Progress; void Prompt(const char *Text); string PromptLine(const char *Text); - bool AskCdromName(string &name) APT_OVERRIDE; + bool AskCdromName(string &name) override; public: - virtual void Update(string text, int current) APT_OVERRIDE; - virtual bool ChangeCdrom() APT_OVERRIDE; - virtual OpProgress* GetOpProgress() APT_OVERRIDE; + void Update(string text, int current) override; + bool ChangeCdrom() override; + OpProgress* GetOpProgress() override; }; void pkgCdromTextStatus::Prompt(const char *Text) diff --git a/cmdline/apt-extracttemplates.h b/cmdline/apt-extracttemplates.h index bbd926e61..e0451ec51 100644 --- a/cmdline/apt-extracttemplates.h +++ b/cmdline/apt-extracttemplates.h @@ -24,10 +24,10 @@ class DebFile : public pkgDirStream public: explicit DebFile(const char *FileName); - ~DebFile(); - bool DoItem(Item &I, int &fd) APT_OVERRIDE; - bool Process(pkgDirStream::Item &I, const unsigned char *data, - unsigned long long size, unsigned long long pos) APT_OVERRIDE; + ~DebFile() override; + bool DoItem(Item &I, int &fd) override; + bool Process(pkgDirStream::Item &I, const unsigned char *data, + unsigned long long size, unsigned long long pos) override; bool Go(); bool ParseInfo(); diff --git a/cmdline/apt-internal-planner.cc b/cmdline/apt-internal-planner.cc index c77997a7a..abd2a7be9 100644 --- a/cmdline/apt-internal-planner.cc +++ b/cmdline/apt-internal-planner.cc @@ -68,17 +68,17 @@ class PMOutput: public pkgPackageManager /*{{{*/ bool const Debug; protected: - virtual bool Install(PkgIterator Pkg,std::string) APT_OVERRIDE + bool Install(PkgIterator Pkg,std::string /*filename*/) override { //std::cerr << "INSTALL: " << APT::PrettyPkg(&Cache, Pkg) << std::endl; return EDSP::WriteSolutionStanza(output, "Unpack", Cache[Pkg].InstVerIter(Cache)); } - virtual bool Configure(PkgIterator Pkg) APT_OVERRIDE + bool Configure(PkgIterator Pkg) override { //std::cerr << "CONFIGURE: " << APT::PrettyPkg(&Cache, Pkg) << " " << std::endl; return EDSP::WriteSolutionStanza(output, "Configure", Cache[Pkg].InstVerIter(Cache)); } - virtual bool Remove(PkgIterator Pkg,bool) APT_OVERRIDE + bool Remove(PkgIterator Pkg, bool /*Purge*/) override { //std::cerr << "REMOVE: " << APT::PrettyPkg(&Cache, Pkg) << " " << std::endl; return EDSP::WriteSolutionStanza(output, "Remove", Pkg.CurrentVer()); -- cgit v1.2.3-70-g09d2 From 9000543eb219f83b6b9592b681fc6811bc56e26f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Dec 2024 21:00:03 +0000 Subject: Drop APT_NORETURN usage [[noreturn]] is a C++11 feature and so we can just use it unconditionally. --- apt-pkg/contrib/gpgv.cc | 2 +- apt-pkg/contrib/gpgv.h | 10 +++++----- apt-pkg/contrib/macros.h | 7 +++++-- apt-pkg/deb/dpkgpm.cc | 2 +- cmdline/apt-internal-planner.cc | 2 +- cmdline/apt-internal-solver.cc | 2 +- methods/basehttp.h | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) (limited to 'cmdline') diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 48d31a44c..59301fa0c 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -290,7 +290,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, bool const Debug = _config->FindB("Debug::Acquire::gpgv", false); struct exiter { std::vector files; - void operator ()(int code) APT_NORETURN { + [[noreturn]] void operator ()(int code) { std::for_each(files.begin(), files.end(), [](auto f) { unlink(f.c_str()); }); exit(code); diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h index 0b84f6bb7..f4f0a2ac7 100644 --- a/apt-pkg/contrib/gpgv.h +++ b/apt-pkg/contrib/gpgv.h @@ -47,11 +47,11 @@ APT_PUBLIC std::pair> FindGPGV(bool * @param fd is used as a pipe for the standard output of gpgv * @param key is the specific one to be used instead of using all */ -APT_PUBLIC void ExecGPGV(std::string const &File, std::string const &FileSig, - int const &statusfd, int fd[2], std::vector const &KeyFiles) APT_NORETURN; -APT_PUBLIC void ExecGPGV(std::string const &File, std::string const &FileSig, - int const &statusfd, int fd[2], std::string const &Key = "") APT_NORETURN; -inline APT_NORETURN void ExecGPGV(std::string const &File, std::string const &FileSig, +[[noreturn]] APT_PUBLIC void ExecGPGV(std::string const &File, std::string const &FileSig, + int const &statusfd, int fd[2], std::vector const &KeyFiles); +[[noreturn]] APT_PUBLIC void ExecGPGV(std::string const &File, std::string const &FileSig, + int const &statusfd, int fd[2], std::string const &Key = ""); +[[noreturn]] inline void ExecGPGV(std::string const &File, std::string const &FileSig, int const &statusfd = -1) { int fd[2]; ExecGPGV(File, FileSig, statusfd, fd); diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index db4932969..c1fa73775 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -40,7 +40,6 @@ #define APT_DEPRECATED_MSG(X) __attribute__ ((deprecated(X))) // __attribute__((const)) is too dangerous for us, we end up using it wrongly #define APT_PURE __attribute__((pure)) - #define APT_NORETURN __attribute__((noreturn)) #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) #define APT_WEAK __attribute__((weak)); #define APT_UNUSED __attribute__((unused)) @@ -48,7 +47,6 @@ #define APT_DEPRECATED #define APT_DEPRECATED_MSG #define APT_PURE - #define APT_NORETURN #define APT_PRINTF(n) #define APT_WEAK #define APT_UNUSED @@ -136,6 +134,11 @@ AptScopeWrapper(F) -> AptScopeWrapper; #define SETFLAG(v,f) ((v) |= FLAG(f)) #define CLRFLAG(v,f) ((v) &=~FLAG(f)) #define CHKFLAG(v,f) ((v) & FLAG(f) ? true : false) +#if APT_GCC_VERSION >= 0x0300 + #define APT_NORETURN __attribute__((noreturn)) +#else + #define APT_NORETURN +#endif #endif #endif #endif diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8cadd2712..d176e85fc 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1488,7 +1488,7 @@ public: auto begin() const { return args.cbegin(); } auto end() const { return args.cend(); } auto& front() const { return args.front(); } - APT_NORETURN void execute(char const *const errmsg) { + [[noreturn]] void execute(char const *const errmsg) { args.push_back(nullptr); execvp(args.front(), &args.front()); std::cerr << errmsg << std::endl; diff --git a/cmdline/apt-internal-planner.cc b/cmdline/apt-internal-planner.cc index abd2a7be9..b850ed628 100644 --- a/cmdline/apt-internal-planner.cc +++ b/cmdline/apt-internal-planner.cc @@ -51,7 +51,7 @@ static bool ShowHelp(CommandLine &) /*{{{*/ return true; } /*}}}*/ -APT_NORETURN static void DIE(std::string const &message) { /*{{{*/ +[[noreturn]] static void DIE(std::string const &message) { /*{{{*/ std::cerr << "ERROR: " << message << std::endl; _error->DumpErrors(std::cerr); exit(EXIT_FAILURE); diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index d596dcb5e..ceedd96c7 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -51,7 +51,7 @@ static bool ShowHelp(CommandLine &) /*{{{*/ return true; } /*}}}*/ -APT_NORETURN static void DIE(std::string const &message) { /*{{{*/ +[[noreturn]] static void DIE(std::string const &message) { /*{{{*/ std::cerr << "ERROR: " << message << std::endl; _error->DumpErrors(std::cerr); exit(EXIT_FAILURE); diff --git a/methods/basehttp.h b/methods/basehttp.h index ee4a84d3d..1d3ed1ace 100644 --- a/methods/basehttp.h +++ b/methods/basehttp.h @@ -163,7 +163,7 @@ class BaseHttpMethod : public aptAuthConfMethod static std::string FailFile; static int FailFd; static time_t FailTime; - static APT_NORETURN void SigTerm(int); + [[noreturn]] static void SigTerm(int); int Loop(); -- cgit v1.2.3-70-g09d2