Przeglądaj źródła

follow method attribute suggestions by gcc

Git-Dch: Ignore
Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn}
David Kalnischkies 12 lat temu
rodzic
commit
a02db58fd5
50 zmienionych plików z 148 dodań i 136 usunięć
  1. 1 1
      apt-inst/extract.cc
  2. 3 3
      apt-inst/filelist.cc
  3. 1 1
      apt-pkg/acquire-item.cc
  4. 3 3
      apt-pkg/acquire.cc
  5. 2 2
      apt-pkg/acquire.h
  6. 1 1
      apt-pkg/algorithms.h
  7. 18 17
      apt-pkg/cacheiterators.h
  8. 5 5
      apt-pkg/cacheset.cc
  9. 5 3
      apt-pkg/contrib/cmndline.h
  10. 3 1
      apt-pkg/contrib/crc-16.h
  11. 4 4
      apt-pkg/contrib/error.h
  12. 1 1
      apt-pkg/contrib/fileutl.h
  13. 1 1
      apt-pkg/contrib/gpgv.h
  14. 1 1
      apt-pkg/contrib/hashes.cc
  15. 1 1
      apt-pkg/contrib/hashes.h
  16. 18 18
      apt-pkg/contrib/strutl.h
  17. 1 1
      apt-pkg/deb/debindexfile.cc
  18. 4 4
      apt-pkg/deb/debindexfile.h
  19. 1 1
      apt-pkg/deb/debsystem.cc
  20. 7 7
      apt-pkg/deb/debversion.h
  21. 2 2
      apt-pkg/depcache.cc
  22. 2 1
      apt-pkg/depcache.h
  23. 1 1
      apt-pkg/edsp/edspindexfile.h
  24. 1 1
      apt-pkg/edsp/edsplistparser.cc
  25. 4 4
      apt-pkg/edsp/edspsystem.h
  26. 2 4
      apt-pkg/indexcopy.cc
  27. 1 1
      apt-pkg/indexfile.h
  28. 7 7
      apt-pkg/indexrecords.cc
  29. 2 2
      apt-pkg/install-progress.cc
  30. 4 4
      apt-pkg/orderlist.h
  31. 1 1
      apt-pkg/packagemanager.h
  32. 8 6
      apt-pkg/pkgcache.h
  33. 1 1
      apt-pkg/pkgcachegen.h
  34. 3 1
      apt-pkg/pkgsystem.cc
  35. 2 2
      apt-pkg/policy.cc
  36. 2 1
      apt-pkg/sourcelist.h
  37. 2 1
      apt-pkg/srcrecords.h
  38. 1 1
      apt-pkg/tagfile.cc
  39. 1 1
      apt-pkg/vendor.cc
  40. 1 1
      apt-pkg/version.h
  41. 7 7
      apt-pkg/versionmatch.h
  42. 1 1
      apt-private/private-cachefile.h
  43. 1 1
      apt-private/private-cmndline.cc
  44. 1 1
      cmdline/apt-cache.cc
  45. 1 1
      cmdline/apt-cdrom.cc
  46. 1 1
      methods/ftp.h
  47. 2 2
      methods/http.cc
  48. 1 1
      methods/rsh.h
  49. 1 1
      methods/server.h
  50. 3 1
      test/libapt/assert.h

+ 1 - 1
apt-inst/extract.cc

@@ -260,7 +260,7 @@ bool pkgExtract::DoItem(Item &Itm, int &/*Fd*/)
 // Extract::Finished - Sequence finished, erase the temp files		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool pkgExtract::Finished()
+APT_CONST bool pkgExtract::Finished()
 {
    return true;
 }

+ 3 - 3
apt-inst/filelist.cc

@@ -85,7 +85,7 @@ pkgFLCache::Header::Header()
 // FLCache::Header::CheckSizes - Check if the two headers have same *sz	/*{{{*/
 // ---------------------------------------------------------------------
 /* Compare to make sure we are matching versions */
-bool pkgFLCache::Header::CheckSizes(Header &Against) const
+APT_PURE bool pkgFLCache::Header::CheckSizes(Header &Against) const
 {
    if (HeaderSz == Against.HeaderSz &&
        NodeSz == Against.NodeSz &&
@@ -353,7 +353,7 @@ pkgFLCache::NodeIterator pkgFLCache::GetNode(const char *Name,
 // ---------------------------------------------------------------------
 /* This is one of two hashing functions. The other is inlined into the
    GetNode routine. */
-pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde)
+APT_PURE pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde)
 {
    // Hash the node
    unsigned long HashPos = 0;
@@ -570,7 +570,7 @@ bool pkgFLCache::AddConfFile(const char *Name,const char *NameEnd,
 // ---------------------------------------------------------------------
 /* Since the package pointer is indirected in all sorts of interesting ways
    this is used to get a pointer to the owning package */
-pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const
+APT_PURE pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const
 {
    if (Nde->Pointer == 0)
       return 0;

+ 1 - 1
apt-pkg/acquire-item.cc

@@ -2162,7 +2162,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 									/*}}}*/
 // AcqArchive::IsTrusted - Determine whether this archive comes from a trusted source /*{{{*/
 // ---------------------------------------------------------------------
-bool pkgAcqArchive::IsTrusted()
+APT_PURE bool pkgAcqArchive::IsTrusted()
 {
    return Trusted;
 }

+ 3 - 3
apt-pkg/acquire.cc

@@ -526,7 +526,7 @@ bool pkgAcquire::Clean(string Dir)
 // Acquire::TotalNeeded - Number of bytes to fetch			/*{{{*/
 // ---------------------------------------------------------------------
 /* This is the total number of bytes needed */
-unsigned long long pkgAcquire::TotalNeeded()
+APT_PURE unsigned long long pkgAcquire::TotalNeeded()
 {
    unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
@@ -537,7 +537,7 @@ unsigned long long pkgAcquire::TotalNeeded()
 // Acquire::FetchNeeded - Number of bytes needed to get			/*{{{*/
 // ---------------------------------------------------------------------
 /* This is the number of bytes that is not local */
-unsigned long long pkgAcquire::FetchNeeded()
+APT_PURE unsigned long long pkgAcquire::FetchNeeded()
 {
    unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
@@ -549,7 +549,7 @@ unsigned long long pkgAcquire::FetchNeeded()
 // Acquire::PartialPresent - Number of partial bytes we already have	/*{{{*/
 // ---------------------------------------------------------------------
 /* This is the number of bytes that is not local */
-unsigned long long pkgAcquire::PartialPresent()
+APT_PURE unsigned long long pkgAcquire::PartialPresent()
 {
   unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)

+ 2 - 2
apt-pkg/acquire.h

@@ -298,7 +298,7 @@ class pkgAcquire
     *  \return the worker immediately following I, or \b NULL if none
     *  exists.
     */
-   Worker *WorkerStep(Worker *I);
+   Worker *WorkerStep(Worker *I) APT_PURE;
 
    /** \brief Get the head of the list of items. */
    inline ItemIterator ItemsBegin() {return Items.begin();};
@@ -481,7 +481,7 @@ class pkgAcquire::Queue
     *  \return the first item in the queue whose URI is #URI and that
     *  is being downloaded by #Owner.
     */
-   QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner);
+   QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner) APT_PURE;
 
    /** Presumably this should start downloading an item?
     *

+ 1 - 1
apt-pkg/algorithms.h

@@ -114,7 +114,7 @@ class pkgProblemResolver						/*{{{*/
    
    // Sort stuff
    static pkgProblemResolver *This;
-   static int ScoreSort(const void *a,const void *b);
+   static int ScoreSort(const void *a,const void *b) APT_PURE;
 
    struct PackageKill
    {

+ 18 - 17
apt-pkg/cacheiterators.h

@@ -30,6 +30,7 @@
 #ifndef PKGLIB_CACHEITERATORS_H
 #define PKGLIB_CACHEITERATORS_H
 #include<apt-pkg/pkgcache.h>
+#include<apt-pkg/macros.h>
 
 #include<iterator>
 #include <iosfwd>
@@ -163,15 +164,15 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
 	inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
 		(S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
 	inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}
-	inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
+	inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
 
-	inline VerIterator VersionList() const;
-	inline VerIterator CurrentVer() const;
-	inline DepIterator RevDependsList() const;
-	inline PrvIterator ProvidesList() const;
-	OkState State() const;
-	const char *CandVersion() const;
-	const char *CurVersion() const;
+	inline VerIterator VersionList() const APT_PURE;
+	inline VerIterator CurrentVer() const APT_PURE;
+	inline DepIterator RevDependsList() const APT_PURE;
+	inline PrvIterator ProvidesList() const APT_PURE;
+	OkState State() const APT_PURE;
+	const char *CandVersion() const APT_PURE;
+	const char *CurVersion() const APT_PURE;
 
 	//Nice printable representation
 	friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
@@ -224,7 +225,7 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 	inline VerFileIterator FileList() const;
 	bool Downloadable() const;
 	inline const char *PriorityType() const {return Owner->Priority(S->Priority);}
-	const char *MultiArchType() const;
+	const char *MultiArchType() const APT_PURE;
 	std::string RelStr() const;
 
 	bool Automatic() const;
@@ -286,13 +287,13 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
 	inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
 	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);}
 	inline bool Reverse() const {return Type == DepRev;}
-	bool IsCritical() const;
-	bool IsNegative() const;
-	bool IsIgnorable(PrvIterator const &Prv) const;
-	bool IsIgnorable(PkgIterator const &Pkg) const;
-	bool IsMultiArchImplicit() const;
-	bool IsSatisfied(VerIterator const &Ver) const;
-	bool IsSatisfied(PrvIterator const &Prv) const;
+	bool IsCritical() const APT_PURE;
+	bool IsNegative() const APT_PURE;
+	bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
+	bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
+	bool IsMultiArchImplicit() const APT_PURE;
+	bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
+	bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
 	void GlobOr(DepIterator &Start,DepIterator &End);
 	Version **AllTargets() const;
 	bool SmartTargetPkg(PkgIterator &Result) const;
@@ -337,7 +338,7 @@ class pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
 	inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}
 	inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);}
 
-	bool IsMultiArchImplicit() const;
+	bool IsMultiArchImplicit() const APT_PURE;
 
 	inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
 	inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :

+ 5 - 5
apt-pkg/cacheset.cc

@@ -614,7 +614,7 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk
 }
 #endif									/*}}}*/
 // canNotFindPackage - handle the case no package is found from a string/*{{{*/
-void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) {
+APT_CONST void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) {
 }
 									/*}}}*/
 // canNotFindAllVer							/*{{{*/
@@ -663,24 +663,24 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache
 }
 									/*}}}*/
 // showTaskSelection							/*{{{*/
-void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/,
+APT_CONST void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/,
 				       std::string const &/*pattern*/) {
 }
 									/*}}}*/
 // showRegExSelection							/*{{{*/
-void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/,
+APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/,
 					std::string const &/*pattern*/) {
 }
 									/*}}}*/
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
 // showFnmatchSelection							/*{{{*/
-void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
+APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
                                           std::string const &pattern) {
 }
 									/*}}}*/
 #endif
 // showSelectedVersion							/*{{{*/
-void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/,
+APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/,
 					 pkgCache::VerIterator const /*Ver*/,
 					 std::string const &/*ver*/,
 					 bool const /*verIsRel*/) {

+ 5 - 3
apt-pkg/contrib/cmndline.h

@@ -44,6 +44,8 @@
 #ifndef PKGLIB_CMNDLINE_H
 #define PKGLIB_CMNDLINE_H
 
+#include <apt-pkg/macros.h>
+
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/configuration.h>
 #endif
@@ -80,14 +82,14 @@ class CommandLine
    
    bool Parse(int argc,const char **argv);
    void ShowHelp();
-   unsigned int FileSize() const;
+   unsigned int FileSize() const APT_PURE;
    bool DispatchArg(Dispatch *List,bool NoMatch = true);
       
    static char const * GetCommand(Dispatch const * const Map,
-	 unsigned int const argc, char const * const * const argv);
+	 unsigned int const argc, char const * const * const argv) APT_PURE;
 
    static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt,
-	 char const *ConfName, unsigned long Flags);
+	 char const *ConfName, unsigned long Flags) APT_CONST;
 
    CommandLine(Args *AList,Configuration *Conf);
    ~CommandLine();

+ 3 - 1
apt-pkg/contrib/crc-16.h

@@ -10,8 +10,10 @@
 #ifndef APTPKG_CRC16_H
 #define APTPKG_CRC16_H
 
+#include <apt-pkg/macros.h>
+
 #define INIT_FCS  0xffff
 unsigned short AddCRC16(unsigned short fcs, void const *buf,
-			unsigned long long len);
+			unsigned long long len) APT_PURE;
 
 #endif

+ 4 - 4
apt-pkg/contrib/error.h

@@ -141,7 +141,7 @@ public:									/*{{{*/
 	 */
 	bool InsertErrno(MsgType type, const char* Function,
 			 const char* Description, va_list &args,
-			 int const errsv, size_t &msgSize);
+			 int const errsv, size_t &msgSize) APT_COLD;
 
 	/** \brief add an fatal error message to the list
 	 *
@@ -225,7 +225,7 @@ public:									/*{{{*/
 	 *
 	 *  \return \b true if an error is included in the list, \b false otherwise
 	 */
-	inline bool PendingError() const {return PendingFlag;};
+	inline bool PendingError() const APT_PURE {return PendingFlag;};
 
 	/** \brief is the list empty?
 	 *
@@ -237,7 +237,7 @@ public:									/*{{{*/
 	 *
 	 *  \return \b true if an the list is empty, \b false otherwise
 	 */
-	bool empty(MsgType const &threshold = WARNING) const;
+	bool empty(MsgType const &threshold = WARNING) const APT_PURE;
 
 	/** \brief returns and removes the first (or last) message in the list
 	 *
@@ -303,7 +303,7 @@ public:									/*{{{*/
 	void MergeWithStack();
 
 	/** \brief return the deep of the stack */
-	size_t StackCount() const {
+	size_t StackCount() const APT_PURE {
 		return Stacks.size();
 	}
 

+ 1 - 1
apt-pkg/contrib/fileutl.h

@@ -119,7 +119,7 @@ class FileFd
    // Simple manipulators
    inline int Fd() {return iFd;};
    inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);};
-   gzFile gzFd() APT_DEPRECATED;
+   gzFile gzFd() APT_DEPRECATED APT_PURE;
 
    inline bool IsOpen() {return iFd >= 0;};
    inline bool Failed() {return (Flags & Fail) == Fail;};

+ 1 - 1
apt-pkg/contrib/gpgv.h

@@ -41,7 +41,7 @@ class FileFd;
  */
 void ExecGPGV(std::string const &File, std::string const &FileSig,
       int const &statusfd, int fd[2]) APT_NORETURN;
-inline void ExecGPGV(std::string const &File, std::string const &FileSig,
+inline APT_NORETURN void ExecGPGV(std::string const &File, std::string const &FileSig,
       int const &statusfd = -1) {
    int fd[2];
    ExecGPGV(File, FileSig, statusfd, fd);

+ 1 - 1
apt-pkg/contrib/hashes.cc

@@ -116,7 +116,7 @@ const char** HashString::SupportedHashes()
    return _SupportedHashes;
 }
 
-bool HashString::empty() const
+APT_PURE bool HashString::empty() const
 {
    return (Type.empty() || Hash.empty());
 }

+ 1 - 1
apt-pkg/contrib/hashes.h

@@ -66,7 +66,7 @@ class HashString
    bool empty() const;
 
    // return the list of hashes we support
-   static const char** SupportedHashes();
+   static APT_CONST const char** SupportedHashes();
 };
 
 class Hashes

+ 18 - 18
apt-pkg/contrib/strutl.h

@@ -107,43 +107,43 @@ int tolower_ascii(int const c) APT_CONST APT_HOT;
 std::string StripEpoch(const std::string &VerStr);
 
 #define APT_MKSTRCMP(name,func) \
-inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \
-inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
-inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \
-inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \
-inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}
+inline APT_PURE int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \
+inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \
+inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}
 
 #define APT_MKSTRCMP2(name,func) \
-inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
-inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \
-inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \
-inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}
+inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \
+inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}
 
-int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
-int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
+int APT_PURE stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
+int APT_PURE stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
 
 /* We assume that GCC 3 indicates that libstdc++3 is in use too. In that
    case the definition of string::const_iterator is not the same as
    const char * and we need these extra functions */
 #if __GNUC__ >= 3
-int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
 	      const char *B,const char *BEnd);
-int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
 	      std::string::const_iterator B,std::string::const_iterator BEnd);
-int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
 		  const char *B,const char *BEnd);
-int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
                   std::string::const_iterator B,std::string::const_iterator BEnd);
 
-inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}
-inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}
+inline APT_PURE int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}
+inline APT_PURE int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}
 #endif
 
 APT_MKSTRCMP2(stringcmp,stringcmp)
 APT_MKSTRCMP2(stringcasecmp,stringcasecmp)
 
 // Return the length of a NULL-terminated string array
-size_t strv_length(const char **str_array);
+size_t APT_PURE strv_length(const char **str_array);
 
 
 inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}

+ 1 - 1
apt-pkg/deb/debindexfile.cc

@@ -660,7 +660,7 @@ pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
 // StatusIndex::Exists - Check if the index is available		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool debStatusIndex::Exists() const
+APT_CONST bool debStatusIndex::Exists() const
 {
    // Abort if the file does not exist.
    return true;

+ 4 - 4
apt-pkg/deb/debindexfile.h

@@ -38,7 +38,7 @@ class debStatusIndex : public pkgIndexFile
 
    public:
 
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
    
    // Interface for acquire
    virtual std::string Describe(bool /*Short*/) const {return File;};
@@ -71,7 +71,7 @@ class debPackagesIndex : public pkgIndexFile
    
    public:
    
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
    // Stuff for accessing files on remote items
    virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
@@ -110,7 +110,7 @@ class debTranslationsIndex : public pkgIndexFile
 
    public:
    
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
    // Interface for acquire
    virtual std::string Describe(bool Short) const;   
@@ -142,7 +142,7 @@ class debSourcesIndex : public pkgIndexFile
    
    public:
 
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
    // Stuff for accessing files on remote items
    virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,

+ 1 - 1
apt-pkg/deb/debsystem.cc

@@ -202,7 +202,7 @@ bool debSystem::Initialize(Configuration &Cnf)
 // ---------------------------------------------------------------------
 /* The standard name for a deb is 'deb'.. There are no separate versions
    of .deb to worry about.. */
-bool debSystem::ArchiveSupported(const char *Type)
+APT_PURE bool debSystem::ArchiveSupported(const char *Type)
 {
    if (strcmp(Type,"deb") == 0)
       return true;

+ 7 - 7
apt-pkg/deb/debversion.h

@@ -19,19 +19,19 @@
 class debVersioningSystem : public pkgVersioningSystem
 {
    public:
-   
+
    static int CmpFragment(const char *A, const char *AEnd, const char *B,
-			  const char *BEnd);
-   
+			  const char *BEnd) APT_PURE;
+
    // Compare versions..
    virtual int DoCmpVersion(const char *A,const char *Aend,
-			  const char *B,const char *Bend);
-   virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer);
-   virtual int DoCmpReleaseVer(const char *A,const char *Aend,
+			  const char *B,const char *Bend) APT_PURE;
+   virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) APT_PURE;
+   virtual APT_PURE int DoCmpReleaseVer(const char *A,const char *Aend,
 			     const char *B,const char *Bend)
    {
       return DoCmpVersion(A,Aend,B,Bend);
-   }   
+   }
    virtual std::string UpstreamVersion(const char *A);
 
    debVersioningSystem();

+ 2 - 2
apt-pkg/depcache.cc

@@ -1691,9 +1691,9 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep)
 }
 									/*}}}*/
 // Policy::GetPriority - Get the priority of the package pin		/*{{{*/
-signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/)
+APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/)
 { return 0; }
-signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/)
+APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/)
 { return 0; }
 									/*}}}*/
 pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()		/*{{{*/

+ 2 - 1
apt-pkg/depcache.h

@@ -41,6 +41,7 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
 
 #include <stddef.h>
 
@@ -239,7 +240,7 @@ class pkgDepCache : protected pkgCache::Namespace
       unsigned char DepState;          // DepState Flags
 
       // Update of candidate version
-      const char *StripEpoch(const char *Ver);
+      const char *StripEpoch(const char *Ver) APT_PURE;
       void Update(PkgIterator Pkg,pkgCache &Cache);
       
       // Various test members for the current status of the package

+ 1 - 1
apt-pkg/edsp/edspindexfile.h

@@ -25,7 +25,7 @@ class edspIndex : public debStatusIndex
 
    public:
 
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
 

+ 1 - 1
apt-pkg/edsp/edsplistparser.cc

@@ -86,7 +86,7 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
 }
 									/*}}}*/
 // ListParser::LoadReleaseInfo - Load the release information		/*{{{*/
-bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/,
+APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/,
 				    FileFd & /*File*/, std::string /*component*/)
 {
    return true;

+ 4 - 4
apt-pkg/edsp/edspsystem.h

@@ -31,11 +31,11 @@ class edspSystem : public pkgSystem
 
    public:
 
-   virtual bool Lock();
-   virtual bool UnLock(bool NoErrors = false);
-   virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const;
+   virtual bool Lock() APT_CONST;
+   virtual bool UnLock(bool NoErrors = false) APT_CONST;
+   virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_CONST;
    virtual bool Initialize(Configuration &Cnf);
-   virtual bool ArchiveSupported(const char *Type);
+   virtual bool ArchiveSupported(const char *Type) APT_CONST;
    virtual signed Score(Configuration const &Cnf);
    virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List);
    virtual bool FindIndex(pkgCache::PkgFileIterator File,

+ 2 - 4
apt-pkg/indexcopy.cc

@@ -642,15 +642,13 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 }
 									/*}}}*/
 // SigVerify::RunGPGV - deprecated wrapper calling ExecGPGV		/*{{{*/
-bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
+APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
       int const &statusfd, int fd[2]) {
    ExecGPGV(File, FileOut, statusfd, fd);
-   return false;
 }
-bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
+APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
       int const &statusfd) {
    ExecGPGV(File, FileOut, statusfd);
-   return false;
 }
 									/*}}}*/
 bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/

+ 1 - 1
apt-pkg/indexfile.h

@@ -54,7 +54,7 @@ class pkgIndexFile
       // Global list of Items supported
       static Type **GlobalList;
       static unsigned long GlobalListLen;
-      static Type *GetType(const char *Type);
+      static Type *GetType(const char *Type) APT_PURE;
 
       const char *Label;
 

+ 7 - 7
apt-pkg/indexrecords.cc

@@ -27,33 +27,33 @@
 
 using std::string;
 
-string indexRecords::GetDist() const
+APT_PURE string indexRecords::GetDist() const
 {
    return this->Dist;
 }
 
-string indexRecords::GetSuite() const
+APT_PURE string indexRecords::GetSuite() const
 {
    return this->Suite;
 }
 
-bool indexRecords::CheckDist(const string MaybeDist) const
+APT_PURE bool indexRecords::CheckDist(const string MaybeDist) const
 {
    return (this->Dist == MaybeDist
 	   || this->Suite == MaybeDist);
 }
 
-string indexRecords::GetExpectedDist() const
+APT_PURE string indexRecords::GetExpectedDist() const
 {
    return this->ExpectedDist;
 }
 
-time_t indexRecords::GetValidUntil() const
+APT_PURE time_t indexRecords::GetValidUntil() const
 {
    return this->ValidUntil;
 }
 
-const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
+APT_PURE const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
 {
    std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
    if (sum == Entries.end())
@@ -61,7 +61,7 @@ const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
    return sum->second;
 }
 
-bool indexRecords::Exists(string const &MetaKey) const
+APT_PURE bool indexRecords::Exists(string const &MetaKey) const
 {
    return Entries.count(MetaKey) == 1;
 }

+ 2 - 2
apt-pkg/install-progress.cc

@@ -93,7 +93,7 @@ void PackageManagerProgressFd::StartDpkg()
    WriteToStatusFd(status.str());
 }
 
-void PackageManagerProgressFd::Stop()
+APT_CONST void PackageManagerProgressFd::Stop()
 {
 }
 
@@ -176,7 +176,7 @@ void PackageManagerProgressDeb822Fd::StartDpkg()
    WriteToStatusFd(status.str());
 }
 
-void PackageManagerProgressDeb822Fd::Stop()
+APT_CONST void PackageManagerProgressDeb822Fd::Stop()
 {
 }
 

+ 4 - 4
apt-pkg/orderlist.h

@@ -70,9 +70,9 @@ class pkgOrderList : protected pkgCache::Namespace
    
    // For pre sorting
    static pkgOrderList *Me;
-   static int OrderCompareA(const void *a, const void *b);
-   static int OrderCompareB(const void *a, const void *b);
-   int FileCmp(PkgIterator A,PkgIterator B);
+   static int OrderCompareA(const void *a, const void *b) APT_PURE;
+   static int OrderCompareB(const void *a, const void *b) APT_PURE;
+   int FileCmp(PkgIterator A,PkgIterator B) APT_PURE;
    
    public:
 
@@ -102,7 +102,7 @@ class pkgOrderList : protected pkgCache::Namespace
    inline void RmFlag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] &= ~F;};
    // IsNow will return true if the Pkg has been not been either configured or unpacked
    inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;};
-   bool IsMissing(PkgIterator Pkg);
+   bool IsMissing(PkgIterator Pkg) APT_PURE;
    void WipeFlags(unsigned long F);
    void SetFileList(std::string *FileList) {this->FileList = FileList;};
 

+ 1 - 1
apt-pkg/packagemanager.h

@@ -75,7 +75,7 @@ class pkgPackageManager : protected pkgCache::Namespace
    bool CreateOrderList();
    
    // Analysis helpers
-   bool DepAlwaysTrue(DepIterator D);
+   bool DepAlwaysTrue(DepIterator D) APT_PURE;
    
    // Install helpers
    bool ConfigureAll();

+ 8 - 6
apt-pkg/pkgcache.h

@@ -74,9 +74,11 @@
 #ifndef PKGLIB_PKGCACHE_H
 #define PKGLIB_PKGCACHE_H
 
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/macros.h>
+
 #include <string>
 #include <time.h>
-#include <apt-pkg/mmap.h>
 
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
@@ -156,8 +158,8 @@ class pkgCache								/*{{{*/
    std::string CacheFile;
    MMap &Map;
 
-   unsigned long sHash(const std::string &S) const;
-   unsigned long sHash(const char *S) const;
+   unsigned long sHash(const std::string &S) const APT_PURE;
+   unsigned long sHash(const char *S) const APT_PURE;
    
    public:
    
@@ -207,8 +209,8 @@ class pkgCache								/*{{{*/
    pkgVersioningSystem *VS;
    
    // Converters
-   static const char *CompTypeDeb(unsigned char Comp);
-   static const char *CompType(unsigned char Comp);
+   static const char *CompTypeDeb(unsigned char Comp) APT_CONST;
+   static const char *CompType(unsigned char Comp) APT_CONST;
    static const char *DepType(unsigned char Dep);
    
    pkgCache(MMap *Map,bool DoMap = true);
@@ -318,7 +320,7 @@ struct pkgCache::Header
    /** \brief Size of the complete cache file */
    unsigned long  CacheFileSize;
 
-   bool CheckSizes(Header &Against) const;
+   bool CheckSizes(Header &Against) const APT_PURE;
    Header();
 };
 									/*}}}*/

+ 1 - 1
apt-pkg/pkgcachegen.h

@@ -104,7 +104,7 @@ class pkgCacheGenerator							/*{{{*/
 
    bool HasFileDeps() {return FoundFileDeps;};
    bool MergeFileProvides(ListParser &List);
-   bool FinishCache(OpProgress *Progress) APT_DEPRECATED;
+   bool FinishCache(OpProgress *Progress) APT_DEPRECATED APT_CONST;
 
    static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
 			MMap **OutMap = 0,bool AllowMem = false);

+ 3 - 1
apt-pkg/pkgsystem.cc

@@ -13,6 +13,8 @@
 #include<config.h>
 
 #include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/macros.h>
+
 #include <cassert>
 #include <cstring>
 									/*}}}*/
@@ -35,7 +37,7 @@ pkgSystem::pkgSystem() : Label(NULL), VS(NULL)
 // System::GetSystem - Get the named system				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgSystem *pkgSystem::GetSystem(const char *Label)
+APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label)
 {
    for (unsigned I = 0; I != GlobalListLen; I++)
       if (strcmp(SysList[I]->Label,Label) == 0)

+ 2 - 2
apt-pkg/policy.cc

@@ -333,7 +333,7 @@ pkgCache::VerIterator pkgPolicy::GetMatch(pkgCache::PkgIterator const &Pkg)
 // Policy::GetPriority - Get the priority of the package pin		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
 {
    if (Pins[Pkg->ID].Type != pkgVersionMatch::None)
    {
@@ -345,7 +345,7 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
    
    return 0;
 }
-signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File)
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File)
 {
    return PFPriority[File->ID];
 }

+ 2 - 1
apt-pkg/sourcelist.h

@@ -29,6 +29,7 @@
 
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
 
 #include <time.h>
 
@@ -63,7 +64,7 @@ class pkgSourceList
       // Global list of Items supported
       static Type **GlobalList;
       static unsigned long GlobalListLen;
-      static Type *GetType(const char *Type);
+      static Type *GetType(const char *Type) APT_PURE;
 
       const char *Name;
       const char *Label;

+ 2 - 1
apt-pkg/srcrecords.h

@@ -13,6 +13,7 @@
 #ifndef PKGLIB_SRCRECORDS_H
 #define PKGLIB_SRCRECORDS_H
 
+#include <apt-pkg/macros.h>
 
 #include <string>
 #include <vector>
@@ -73,7 +74,7 @@ class pkgSrcRecords
 
       //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
       virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
-      static const char *BuildDepType(unsigned char const &Type);
+      static const char *BuildDepType(unsigned char const &Type) APT_PURE;
 
       virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
       

+ 1 - 1
apt-pkg/tagfile.cc

@@ -85,7 +85,7 @@ pkgTagFile::~pkgTagFile()
 }
 									/*}}}*/
 // TagFile::Offset - Return the current offset in the buffer		/*{{{*/
-unsigned long pkgTagFile::Offset()
+APT_PURE unsigned long pkgTagFile::Offset()
 {
    return d->iOffset;
 }

+ 1 - 1
apt-pkg/vendor.cc

@@ -35,7 +35,7 @@ const std::string Vendor::LookupFingerprint(std::string Print) const
       return (*Elt).second;
 }
 
-bool Vendor::CheckDist(std::string /*Dist*/)
+APT_CONST bool Vendor::CheckDist(std::string /*Dist*/)
 {
    return true;
 }

+ 1 - 1
apt-pkg/version.h

@@ -33,7 +33,7 @@ class pkgVersioningSystem
    // Global list of VS's
    static pkgVersioningSystem **GlobalList;
    static unsigned long GlobalListLen;
-   static pkgVersioningSystem *GetVS(const char *Label);
+   static pkgVersioningSystem *GetVS(const char *Label) APT_PURE;
    
    const char *Label;
    

+ 7 - 7
apt-pkg/versionmatch.h

@@ -45,7 +45,7 @@ using std::string;
 #endif
 
 class pkgVersionMatch
-{   
+{
    // Version Matching
    std::string VerStr;
    bool VerPrefixMatch;
@@ -61,20 +61,20 @@ class pkgVersionMatch
    std::string RelComponent;
    std::string RelArchitecture;
    bool MatchAll;
-   
+
    // Origin Matching
    std::string OrSite;
-   
+
    public:
-   
+
    enum MatchType {None = 0,Version,Release,Origin} Type;
-   
-   bool MatchVer(const char *A,std::string B,bool Prefix);
+
+   bool MatchVer(const char *A,std::string B,bool Prefix) APT_PURE;
    bool ExpressionMatches(const char *pattern, const char *string);
    bool ExpressionMatches(const std::string& pattern, const char *string);
    bool FileMatch(pkgCache::PkgFileIterator File);
    pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg);
-			       
+
    pkgVersionMatch(std::string Data,MatchType Type);
 };
 

+ 1 - 1
apt-private/private-cachefile.h

@@ -13,7 +13,7 @@
 class CacheFile : public pkgCacheFile
 {
    static pkgCache *SortCache;
-   static int NameComp(const void *a,const void *b);
+   static int NameComp(const void *a,const void *b) APT_PURE;
    
    public:
    pkgCache::Package **List;

+ 1 - 1
apt-private/private-cmndline.cc

@@ -12,7 +12,7 @@
 #include <apti18n.h>
 									/*}}}*/
 
-static bool strcmp_match_in_list(char const * const Cmd, ...)		/*{{{*/
+APT_SENTINEL static bool strcmp_match_in_list(char const * const Cmd, ...)		/*{{{*/
 {
    va_list args;
    bool found = false;

+ 1 - 1
cmdline/apt-cache.cc

@@ -1118,7 +1118,7 @@ static bool Dotty(CommandLine &CmdL)
 /* This displays the package record from the proper package index file. 
    It is not used by DumpAvail for performance reasons. */
 
-static unsigned char const* skipDescriptionFields(unsigned char const * DescP)
+static APT_PURE unsigned char const* skipDescriptionFields(unsigned char const * DescP)
 {
    char const * const TagName = "\nDescription";
    size_t const TagLen = strlen(TagName);

+ 1 - 1
cmdline/apt-cdrom.cc

@@ -98,7 +98,7 @@ bool pkgCdromTextStatus::ChangeCdrom()
    return true;
 }
 
-OpProgress* pkgCdromTextStatus::GetOpProgress()
+APT_CONST OpProgress* pkgCdromTextStatus::GetOpProgress()
 {
    return &Progress;
 }

+ 1 - 1
methods/ftp.h

@@ -78,7 +78,7 @@ class FtpMethod : public pkgAcqMethod
    static std::string FailFile;
    static int FailFd;
    static time_t FailTime;
-   static void SigTerm(int);
+   static APT_NORETURN void SigTerm(int);
    
    public:
    

+ 2 - 2
methods/http.cc

@@ -470,7 +470,7 @@ bool HttpServerState::WriteResponse(const std::string &Data)		/*{{{*/
    return Out.Read(Data);
 }
 									/*}}}*/
-bool HttpServerState::IsOpen()						/*{{{*/
+APT_PURE bool HttpServerState::IsOpen()					/*{{{*/
 {
    return (ServerFd != -1);
 }
@@ -485,7 +485,7 @@ bool HttpServerState::InitHashes(FileFd &File)				/*{{{*/
    return In.Hash->AddFD(File, StartPos);
 }
 									/*}}}*/
-Hashes * HttpServerState::GetHashes()					/*{{{*/
+APT_PURE Hashes * HttpServerState::GetHashes()				/*{{{*/
 {
    return In.Hash;
 }

+ 1 - 1
methods/rsh.h

@@ -64,7 +64,7 @@ class RSHMethod : public pkgAcqMethod
    static std::string FailFile;
    static int FailFd;
    static time_t FailTime;
-   static void SigTerm(int);
+   static APT_NORETURN void SigTerm(int);
 
    public:
 

+ 1 - 1
methods/server.h

@@ -129,7 +129,7 @@ class ServerMethod : public pkgAcqMethod
    static std::string FailFile;
    static int FailFd;
    static time_t FailTime;
-   static void SigTerm(int);
+   static APT_NORETURN void SigTerm(int);
 
    virtual bool Configuration(std::string Message);
    virtual bool Flush() { return Server->Flush(File); };

+ 3 - 1
test/libapt/assert.h

@@ -1,6 +1,8 @@
 #include <iostream>
 #include <cstdlib>
 
+#include <apt-pkg/macros.h>
+
 #if __GNUC__ >= 4
 	#pragma GCC diagnostic push
 	#pragma GCC diagnostic ignored "-Wmissing-declarations"
@@ -10,7 +12,7 @@
 #define equalsNot(x,y) assertEqualsNot(y, x, __LINE__)
 
 template < typename X, typename Y >
-void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) {
+APT_NORETURN void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) {
 	std::cerr << "Test FAILED: »" << expect << "« " << compare << " »" << get << "« at line " << line << std::endl;
 	std::exit(EXIT_FAILURE);
 }