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/contrib/cdromutl.cc | 5 ++++- apt-pkg/contrib/cmndline.cc | 5 +++++ apt-pkg/contrib/configuration.cc | 13 ++++++++++--- apt-pkg/contrib/error.cc | 4 +++- apt-pkg/contrib/error.h | 27 ++++++++++++++------------- apt-pkg/contrib/fileutl.cc | 12 +++++++++--- apt-pkg/contrib/fileutl.h | 11 ++++++----- apt-pkg/contrib/gpgv.cc | 18 ++++++++++-------- apt-pkg/contrib/gpgv.h | 14 ++++++-------- apt-pkg/contrib/hashes.cc | 6 +++++- apt-pkg/contrib/hashes.h | 13 +++++++++---- apt-pkg/contrib/hashsum.cc | 3 +++ apt-pkg/contrib/hashsum_template.h | 10 +++++++--- apt-pkg/contrib/macros.h | 8 ++++---- apt-pkg/contrib/md5.cc | 6 +----- apt-pkg/contrib/md5.h | 9 +++++---- apt-pkg/contrib/mmap.cc | 4 ++-- apt-pkg/contrib/netrc.cc | 3 +-- apt-pkg/contrib/netrc.h | 6 ++++-- apt-pkg/contrib/progress.cc | 2 ++ apt-pkg/contrib/sha1.cc | 5 +---- apt-pkg/contrib/sha1.h | 7 ++++--- apt-pkg/contrib/sha2.h | 10 +++++++--- apt-pkg/contrib/sha2_internal.cc | 1 + apt-pkg/contrib/sha2_internal.h | 1 + apt-pkg/contrib/strutl.cc | 9 +++++++-- apt-pkg/contrib/strutl.h | 23 +++++++++++++---------- 27 files changed, 144 insertions(+), 91 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 20210ec0a..096d3bcf5 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -19,7 +19,10 @@ #include #include -#include +#include +#include +#include +#include #include #include #include diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index ed5800007..3799c822d 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -18,6 +18,11 @@ #include #include +#include +#include +#include +#include + #include /*}}}*/ using namespace std; diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 003fd01d8..00f6ad0f9 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -21,11 +21,18 @@ #include #include #include -#include - +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index 2d25f5ed9..892cd4874 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -17,12 +17,14 @@ #include +#include +#include +#include #include #include #include #include #include - #include #include diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h index c06e45ee4..919b1e6d4 100644 --- a/apt-pkg/contrib/error.h +++ b/apt-pkg/contrib/error.h @@ -46,6 +46,7 @@ #include #include +#include #include class GlobalError /*{{{*/ @@ -73,7 +74,7 @@ public: /*{{{*/ * * \return \b false */ - bool FatalE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool FatalE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add an Error message with errno to the list * @@ -82,7 +83,7 @@ public: /*{{{*/ * * \return \b false */ - bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool Errno(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add a warning message with errno to the list * @@ -94,7 +95,7 @@ public: /*{{{*/ * * \return \b false */ - bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool WarningE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add a notice message with errno to the list * @@ -103,7 +104,7 @@ public: /*{{{*/ * * \return \b false */ - bool NoticeE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool NoticeE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add a debug message with errno to the list * @@ -112,7 +113,7 @@ public: /*{{{*/ * * \return \b false */ - bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool DebugE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief adds an errno message with the given type * @@ -121,7 +122,7 @@ public: /*{{{*/ * \param Description of the error */ bool InsertErrno(MsgType const &type, const char* Function, - const char* Description,...) __like_printf(4) __cold; + const char* Description,...) APT_PRINTF(4) APT_COLD; /** \brief adds an errno message with the given type * @@ -155,7 +156,7 @@ public: /*{{{*/ * * \return \b false */ - bool Fatal(const char *Description,...) __like_printf(2) __cold; + bool Fatal(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add an Error message to the list * @@ -163,7 +164,7 @@ public: /*{{{*/ * * \return \b false */ - bool Error(const char *Description,...) __like_printf(2) __cold; + bool Error(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add a warning message to the list * @@ -174,7 +175,7 @@ public: /*{{{*/ * * \return \b false */ - bool Warning(const char *Description,...) __like_printf(2) __cold; + bool Warning(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add a notice message to the list * @@ -187,7 +188,7 @@ public: /*{{{*/ * * \return \b false */ - bool Notice(const char *Description,...) __like_printf(2) __cold; + bool Notice(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add a debug message to the list * @@ -195,14 +196,14 @@ public: /*{{{*/ * * \return \b false */ - bool Debug(const char *Description,...) __like_printf(2) __cold; + bool Debug(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief adds an error message with the given type * * \param type of the error message * \param Description of the error */ - bool Insert(MsgType const &type, const char* Description,...) __like_printf(3) __cold; + bool Insert(MsgType const &type, const char* Description,...) APT_PRINTF(3) APT_COLD; /** \brief adds an error message with the given type * @@ -218,7 +219,7 @@ public: /*{{{*/ * should call this method again in that case */ bool Insert(MsgType type, const char* Description, - va_list &args, size_t &msgSize) __cold; + va_list &args, size_t &msgSize) APT_COLD; /** \brief is an error in the list? * diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 464950abd..55ba41128 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -26,16 +26,22 @@ #include #include #include - +#include + +#include +#include +#include +#include +#include +#include +#include #include #include #include - #include #include #include #include -#include #include #include #include diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index e752e9621..6fdea1294 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -94,7 +95,7 @@ class FileFd And as the auto-conversation converts a 'unsigned long *' to a 'bool' instead of 'unsigned long long *' we need to provide this explicitely - otherwise applications magically start to fail… */ - __deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual) + bool Read(void *To,unsigned long long Size,unsigned long *Actual) APT_DEPRECATED { unsigned long long R; bool const T = Read(To, Size, &R); @@ -118,7 +119,7 @@ class FileFd // Simple manipulators inline int Fd() {return iFd;}; inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);}; - __deprecated gzFile gzFd(); + gzFile gzFd() APT_DEPRECATED; inline bool IsOpen() {return iFd >= 0;}; inline bool Failed() {return (Flags & Fail) == Fail;}; @@ -152,8 +153,8 @@ class FileFd bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor); // private helpers to set Fail flag and call _error->Error - bool FileFdErrno(const char* Function, const char* Description,...) __like_printf(3) __cold; - bool FileFdError(const char* Description,...) __like_printf(2) __cold; + bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD; + bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD; }; bool RunScripts(const char *Cnf); @@ -161,7 +162,7 @@ bool CopyFile(FileFd &From,FileFd &To); int GetLock(std::string File,bool Errors = true); bool FileExists(std::string File); bool RealFileExists(std::string File); -bool DirectoryExists(std::string const &Path) __attrib_const; +bool DirectoryExists(std::string const &Path) APT_CONST; bool CreateDirectory(std::string const &Parent, std::string const &Path); time_t GetModificationTime(std::string const &Path); diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 9de227062..f24dd9640 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -2,21 +2,23 @@ // Include Files /*{{{*/ #include +#include +#include +#include +#include +#include + #include #include #include #include #include -#include -#include #include #include - -#include -#include -#include -#include -#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h index d9712d6a8..ab3c68de5 100644 --- a/apt-pkg/contrib/gpgv.h +++ b/apt-pkg/contrib/gpgv.h @@ -9,17 +9,17 @@ #ifndef CONTRIB_GPGV_H #define CONTRIB_GPGV_H +#include + #include #include +#ifndef APT_10_CLEANER_HEADERS #include - -#if __GNUC__ >= 4 - #define APT_noreturn __attribute__ ((noreturn)) -#else - #define APT_noreturn /* no support */ #endif +class FileFd; + /** \brief generates and run the command to verify a file with gpgv * * If File and FileSig specify the same file it is assumed that we @@ -40,15 +40,13 @@ * @param FileSig is the signature (detached or clear-signed) */ void ExecGPGV(std::string const &File, std::string const &FileSig, - int const &statusfd, int fd[2]) APT_noreturn; + int const &statusfd, int fd[2]) APT_NORETURN; inline void ExecGPGV(std::string const &File, std::string const &FileSig, int const &statusfd = -1) { int fd[2]; ExecGPGV(File, FileSig, statusfd, fd); } -#undef APT_noreturn - /** \brief Split an inline signature into message and signature * * Takes a clear-signed message and puts the first signed message diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 890573d9c..5efafa511 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -16,8 +16,12 @@ #include #include #include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 636cad257..979ee1eb8 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -17,17 +17,22 @@ #include #include #include -#include -#include -#include #include - +#include #ifndef APT_8_CLEANER_HEADERS using std::min; using std::vector; #endif +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif + + +class FileFd; // helper class that contains hash function name // and hash diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index d02177724..25ccc187d 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -1,6 +1,9 @@ // Cryptographic API Base #include +#include + +#include #include #include "hashsum_template.h" diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index f96188eb8..869dc5cb7 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -10,20 +10,24 @@ #ifndef APTPKG_HASHSUM_TEMPLATE_H #define APTPKG_HASHSUM_TEMPLATE_H -#include #include #include -#include -#include #include +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; #endif +class FileFd; + template class HashSumValue { diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index 294242e68..d97053553 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -71,13 +71,13 @@ #endif #if APT_GCC_VERSION >= 0x0300 - #define APT_UNUSED __attribute__((unused)) + #define APT_DEPRECATED __attribute__ ((deprecated)) #define APT_CONST __attribute__((const)) #define APT_PURE __attribute__((pure)) #define APT_NORETURN __attribute__((noreturn)) #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) #else - #define APT_UNUSED + #define APT_DEPRECATED #define APT_CONST #define APT_PURE #define APT_NORETURN @@ -103,8 +103,8 @@ #define APT_COLD __attribute__ ((__cold__)) #define APT_HOT __attribute__ ((__hot__)) #else - #define __cold - #define __hot + #define APT_COLD + #define APT_HOT #endif #ifndef APT_10_CLEANER_HEADERS diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc index 4351aeb22..b487a96f9 100644 --- a/apt-pkg/contrib/md5.cc +++ b/apt-pkg/contrib/md5.cc @@ -38,13 +38,9 @@ #include #include -#include -#include +#include #include -#include -#include // For htonl -#include /*}}}*/ // byteSwap - Swap bytes in a buffer /*{{{*/ diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h index 195455645..f4992c223 100644 --- a/apt-pkg/contrib/md5.h +++ b/apt-pkg/contrib/md5.h @@ -23,14 +23,15 @@ #ifndef APTPKG_MD5_H #define APTPKG_MD5_H - -#include -#include -#include #include #include "hashsum_template.h" +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 37acba340..b2a53a6cb 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -22,11 +22,11 @@ #include #include #include +#include +#include #include -#include #include -#include #include #include #include diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 32b146581..feaed67c8 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -15,14 +15,13 @@ #include #include -#include -#include #include #include #include #include #include +#include #include #include "netrc.h" diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 6feb5b726..dbeb45386 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -16,6 +16,8 @@ #include +#include + #ifndef APT_8_CLEANER_HEADERS #include #endif @@ -25,9 +27,9 @@ class URI; -// kill this export on the next ABI break - strongly doubt its in use anyway +// FIXME: kill this export on the next ABI break - strongly doubt its in use anyway // outside of the apt itself, its really a internal interface -__deprecated int parsenetrc (char *host, char *login, char *password, char *filename); +APT_DEPRECATED int parsenetrc (char *host, char *login, char *password, char *filename); void maybe_add_auth (URI &Uri, std::string NetRCFile); #endif diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 9d74ed495..4ff4f181d 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include #include diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc index b5a6a2440..bf6bc6cb6 100644 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@ -32,12 +32,9 @@ #include #include -#include -#include +#include #include -#include -#include /*}}}*/ // SHA1Transform - Alters an existing SHA-1 hash /*{{{*/ diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h index a8d55eb13..5770c315a 100644 --- a/apt-pkg/contrib/sha1.h +++ b/apt-pkg/contrib/sha1.h @@ -14,12 +14,13 @@ #ifndef APTPKG_SHA1_H #define APTPKG_SHA1_H +#include "hashsum_template.h" + +#ifndef APT_10_CLEANER_HEADERS #include #include #include - -#include "hashsum_template.h" - +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h index 8e0c99a1b..a25ad4d32 100644 --- a/apt-pkg/contrib/sha2.h +++ b/apt-pkg/contrib/sha2.h @@ -14,14 +14,18 @@ #ifndef APTPKG_SHA2_H #define APTPKG_SHA2_H -#include #include -#include -#include #include "sha2_internal.h" #include "hashsum_template.h" +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif + + typedef HashSumValue<512> SHA512SumValue; typedef HashSumValue<256> SHA256SumValue; diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index bb2560252..131ff5beb 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -33,6 +33,7 @@ */ #include +#include #include /* memcpy()/memset() or bcopy()/bzero() */ #include /* assert() */ #include "sha2_internal.h" diff --git a/apt-pkg/contrib/sha2_internal.h b/apt-pkg/contrib/sha2_internal.h index d9d429c92..1b82d965d 100644 --- a/apt-pkg/contrib/sha2_internal.h +++ b/apt-pkg/contrib/sha2_internal.h @@ -44,6 +44,7 @@ #ifdef SHA2_USE_INTTYPES_H +#include #include #endif /* SHA2_USE_INTTYPES_H */ diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 61fcc6a7d..2100ee47b 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -21,6 +21,11 @@ #include #include +#include +#include +#include +#include +#include #include #include #include @@ -33,9 +38,9 @@ #include #include - -using namespace std; /*}}}*/ +using namespace std; + // Strip - Remove white space from the front and back of a string /*{{{*/ // --------------------------------------------------------------------- namespace APT { diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 3a6d38b75..79479957d 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -18,15 +18,18 @@ #include -#include #include #include #include #include #include +#include #include "macros.h" +#ifndef APT_10_CLEANER_HEADERS +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::vector; @@ -60,9 +63,9 @@ std::string Base64Encode(const std::string &Str); std::string OutputInDepth(const unsigned long Depth, const char* Separator=" "); std::string URItoFileName(const std::string &URI); std::string TimeRFC1123(time_t Date); -bool RFC1123StrToTime(const char* const str,time_t &time) __must_check; -bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check; -__deprecated bool StrToTime(const std::string &Val,time_t &Result); +bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK; +bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK; +APT_DEPRECATED bool StrToTime(const std::string &Val,time_t &Result); std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0); int StringToBool(const std::string &Text,int Default = -1); bool ReadMessages(int Fd, std::vector &List); @@ -76,7 +79,7 @@ bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); // split a given string by a char -std::vector VectorizeString(std::string const &haystack, char const &split) __attrib_const; +std::vector VectorizeString(std::string const &haystack, char const &split) APT_CONST; /* \brief Return a vector of strings from string "input" where "sep" * is used as the delimiter string. @@ -94,13 +97,13 @@ std::vector VectorizeString(std::string const &haystack, char const */ std::vector StringSplit(std::string const &input, std::string const &sep, - unsigned int maxsplit=std::numeric_limits::max()) __attrib_const; + unsigned int maxsplit=std::numeric_limits::max()) APT_CONST; -void ioprintf(std::ostream &out,const char *format,...) __like_printf(2); -void strprintf(std::string &out,const char *format,...) __like_printf(2); -char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3); +void ioprintf(std::ostream &out,const char *format,...) APT_PRINTF(2); +void strprintf(std::string &out,const char *format,...) APT_PRINTF(2); +char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_PRINTF(3); bool CheckDomainList(const std::string &Host, const std::string &List); -int tolower_ascii(int const c) __attrib_const __hot; +int tolower_ascii(int const c) APT_CONST APT_HOT; std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ -- cgit v1.2.3