From: David Kalnischkies Date: Tue, 16 Jun 2015 22:14:10 +0000 (+0200) Subject: apply various style suggestions by cppcheck X-Git-Tag: 1.1.exp9~128 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/e8afd16892e87a6e2f17c1019ee455f5583387c2?ds=sidebyside;hp=3d5e93f7cd6bea364ca811c7f64b5e1d4174a4ac apply various style suggestions by cppcheck Some of them modify the ABI, but given that we prepare a big one already, these few hardly count for much. Git-Dch: Ignore --- diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 3313aaabc..034b7725a 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -120,7 +120,7 @@ static bool AllowInsecureRepositories(indexRecords const * const MetaIndexParser return false; } /*}}}*/ -static HashStringList GetExpectedHashesFromFor(indexRecords * const Parser, std::string const MetaKey)/*{{{*/ +static HashStringList GetExpectedHashesFromFor(indexRecords * const Parser, std::string const &MetaKey)/*{{{*/ { if (Parser == NULL) return HashStringList(); @@ -393,7 +393,7 @@ class APT_HIDDEN NoActionItem : public pkgAcquire::Item /*{{{*/ virtual std::string DescURI() const {return Target.URI;}; virtual HashStringList GetExpectedHashes() const {return HashStringList();}; - NoActionItem(pkgAcquire * const Owner, IndexTarget const Target) : + NoActionItem(pkgAcquire * const Owner, IndexTarget const &Target) : pkgAcquire::Item(Owner), Target(Target) { Status = StatDone; @@ -404,9 +404,9 @@ class APT_HIDDEN NoActionItem : public pkgAcquire::Item /*{{{*/ // Acquire::Item::Item - Constructor /*{{{*/ APT_IGNORE_DEPRECATED_PUSH -pkgAcquire::Item::Item(pkgAcquire * const Owner) : +pkgAcquire::Item::Item(pkgAcquire * const owner) : FileSize(0), PartialSize(0), Mode(0), ID(0), Complete(false), Local(false), - QueueCounter(0), ExpectedAdditionalItems(0), Owner(Owner) + QueueCounter(0), ExpectedAdditionalItems(0), Owner(owner) { Owner->Add(this); Status = StatIdle; @@ -661,8 +661,8 @@ std::string pkgAcquire::Item::HashSum() const /*{{{*/ /*}}}*/ pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner, /*{{{*/ - pkgAcqMetaBase * const TransactionManager, IndexTarget const Target) : - pkgAcquire::Item(Owner), Target(Target), TransactionManager(TransactionManager) + pkgAcqMetaBase * const transactionManager, IndexTarget const &target) : + pkgAcquire::Item(Owner), Target(target), TransactionManager(transactionManager) { if (TransactionManager != this) TransactionManager->Add(this); @@ -672,7 +672,7 @@ pkgAcqTransactionItem::~pkgAcqTransactionItem() /*{{{*/ { } /*}}}*/ -HashStringList pkgAcqTransactionItem::GetExpectedHashesFor(std::string const MetaKey) const /*{{{*/ +HashStringList pkgAcqTransactionItem::GetExpectedHashesFor(std::string const &MetaKey) const /*{{{*/ { return GetExpectedHashesFromFor(TransactionManager->MetaIndexParser, MetaKey); } @@ -681,7 +681,7 @@ HashStringList pkgAcqTransactionItem::GetExpectedHashesFor(std::string const Met // AcqMetaBase - Constructor /*{{{*/ pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - std::vector const IndexTargets, + std::vector const &IndexTargets, IndexTarget const &DataTarget, indexRecords * const MetaIndexParser) : pkgAcqTransactionItem(Owner, TransactionManager, DataTarget), @@ -1103,11 +1103,11 @@ pkgAcqMetaBase::~pkgAcqMetaBase() {} pkgAcqMetaClearSig::pkgAcqMetaClearSig(pkgAcquire * const Owner, /*{{{*/ IndexTarget const &ClearsignedTarget, IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget, - std::vector const IndexTargets, + std::vector const &IndexTargets, indexRecords * const MetaIndexParser) : pkgAcqMetaIndex(Owner, this, ClearsignedTarget, DetachedSigTarget, IndexTargets, MetaIndexParser), ClearsignedTarget(ClearsignedTarget), - DetachedDataTarget(DetachedDataTarget), DetachedSigTarget(DetachedSigTarget) + DetachedDataTarget(DetachedDataTarget) { // index targets + (worst case:) Release/Release.gpg ExpectedAdditionalItems = IndexTargets.size() + 2; @@ -1243,7 +1243,7 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire * const Owner, /*{{{*/ pkgAcqMetaBase * const TransactionManager, IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget, - vector const IndexTargets, + vector const &IndexTargets, indexRecords * const MetaIndexParser) : pkgAcqMetaBase(Owner, TransactionManager, IndexTargets, DataTarget, MetaIndexParser), DetachedSigTarget(DetachedSigTarget) @@ -1325,7 +1325,7 @@ pkgAcqMetaIndex::~pkgAcqMetaIndex() {} // AcqMetaSig::AcqMetaSig - Constructor /*{{{*/ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target, + IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex) : pkgAcqTransactionItem(Owner, TransactionManager, Target), MetaIndex(MetaIndex) { @@ -1488,7 +1488,7 @@ void pkgAcqMetaSig::Failed(string const &Message,pkgAcquire::MethodConfig const // AcqBaseIndex - Constructor /*{{{*/ pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target) + IndexTarget const &Target) : pkgAcqTransactionItem(Owner, TransactionManager, Target) { } @@ -1504,7 +1504,7 @@ pkgAcqBaseIndex::~pkgAcqBaseIndex() {} */ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target) + IndexTarget const &Target) : pkgAcqBaseIndex(Owner, TransactionManager, Target) { Debug = _config->FindB("Debug::pkgAcquire::Diffs",false); @@ -1905,7 +1905,7 @@ pkgAcqDiffIndex::~pkgAcqDiffIndex() {} */ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target, + IndexTarget const &Target, vector const &diffs) : pkgAcqBaseIndex(Owner, TransactionManager, Target), available_patches(diffs) @@ -2128,7 +2128,7 @@ pkgAcqIndexDiffs::~pkgAcqIndexDiffs() {} // AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target, + IndexTarget const &Target, DiffInfo const &patch, std::vector const * const allPatches) : pkgAcqBaseIndex(Owner, TransactionManager, Target), @@ -2273,8 +2273,8 @@ pkgAcqIndexMergeDiffs::~pkgAcqIndexMergeDiffs() {} // AcqIndex::AcqIndex - Constructor /*{{{*/ pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target) - : pkgAcqBaseIndex(Owner, TransactionManager, Target) + IndexTarget const &Target) + : pkgAcqBaseIndex(Owner, TransactionManager, Target), Stage(STAGE_DOWNLOAD) { // autoselect the compression method AutoSelectCompression(); diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index df1380b5e..36fedc7be 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -276,7 +276,7 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/ * * \param Owner The new owner of this item. */ - Item(pkgAcquire * const Owner); + explicit Item(pkgAcquire * const Owner); /** \brief Remove this item from its owner's queue by invoking * pkgAcquire::Remove. @@ -347,7 +347,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/ void *d; protected: IndexTarget const Target; - HashStringList GetExpectedHashesFor(std::string const MetaKey) const; + HashStringList GetExpectedHashesFor(std::string const &MetaKey) const; bool QueueURI(pkgAcquire::ItemDesc &Item); @@ -370,7 +370,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/ virtual bool HashesRequired() const; - pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target); + pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const &Target); virtual ~pkgAcqTransactionItem(); friend class pkgAcqMetaBase; @@ -474,7 +474,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/ virtual std::string GetFinalFilename() const; pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - std::vector const IndexTargets, + std::vector const &IndexTargets, IndexTarget const &DataTarget, indexRecords* const MetaIndexParser); virtual ~pkgAcqMetaBase(); @@ -511,7 +511,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget, - std::vector const IndexTargets, indexRecords * const MetaIndexParser); + std::vector const &IndexTargets, indexRecords * const MetaIndexParser); virtual ~pkgAcqMetaIndex(); friend class pkgAcqMetaSig; @@ -548,7 +548,7 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem pkgAcquire::MethodConfig const * const Cnf); /** \brief Create a new pkgAcqMetaSig. */ - pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target, + pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex); virtual ~pkgAcqMetaSig(); }; @@ -560,7 +560,6 @@ class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex IndexTarget const ClearsignedTarget; IndexTarget const DetachedDataTarget; - IndexTarget const DetachedSigTarget; public: virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf); @@ -573,7 +572,7 @@ public: IndexTarget const &ClearsignedTarget, IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget, - std::vector const IndexTargets, + std::vector const &IndexTargets, indexRecords * const MetaIndexParser); virtual ~pkgAcqMetaClearSig(); }; @@ -588,7 +587,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem virtual std::string GetFinalFilename() const; pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target); + IndexTarget const &Target); virtual ~pkgAcqBaseIndex(); }; /*}}}*/ @@ -652,7 +651,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex * \param ShortDesc A short description of the list file to download. */ pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target); + IndexTarget const &Target); virtual ~pkgAcqDiffIndex(); private: APT_HIDDEN void QueueOnIMSHit() const; @@ -751,7 +750,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * check if it was the last one to complete the download step */ pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target, DiffInfo const &patch, + IndexTarget const &Target, DiffInfo const &patch, std::vector const * const allPatches); virtual ~pkgAcqIndexMergeDiffs(); }; @@ -865,7 +864,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex * that depends on it. */ pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target, + IndexTarget const &Target, std::vector const &diffs=std::vector()); virtual ~pkgAcqIndexDiffs(); }; @@ -943,7 +942,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex virtual std::string GetMetaKey() const; pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const Target); + IndexTarget const &Target); virtual ~pkgAcqIndex(); private: diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index ef195d44b..55fa5734f 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -47,7 +47,7 @@ using namespace std; // --------------------------------------------------------------------- /* */ pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf, - pkgAcquireStatus *Log) : Log(Log) + pkgAcquireStatus *log) : Log(log) { OwnerQ = Q; Config = Cnf; diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index b8e8fefed..31b9d3b88 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -317,7 +317,7 @@ class pkgAcquire::Worker : public WeakPointable * \param Config A location in which to store information about * the fetch method. */ - Worker(MethodConfig *Config); + explicit Worker(MethodConfig *Config); /** \brief Clean up this worker. * diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 75df858a8..f70feeeec 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -653,8 +653,8 @@ pkgAcquire::MethodConfig::MethodConfig() : d(NULL), Next(0), SingleInstance(fals // Queue::Queue - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgAcquire::Queue::Queue(string Name,pkgAcquire *Owner) : d(NULL), Next(0), - Name(Name), Items(0), Workers(0), Owner(Owner), PipeDepth(0), MaxPipeDepth(1) +pkgAcquire::Queue::Queue(string const &name,pkgAcquire * const owner) : d(NULL), Next(0), + Name(name), Items(0), Workers(0), Owner(owner), PipeDepth(0), MaxPipeDepth(1) { } /*}}}*/ diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index b7e6c68f1..661b35f34 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -369,7 +369,7 @@ class pkgAcquire bool GetLock(std::string const &Lock); /** \brief Construct a new pkgAcquire. */ - pkgAcquire(pkgAcquireStatus *Log); + explicit pkgAcquire(pkgAcquireStatus *Log); pkgAcquire(); /** \brief Destroy this pkgAcquire object. @@ -584,7 +584,7 @@ class pkgAcquire::Queue * \param Name The name of the new queue. * \param Owner The download process that owns the new queue. */ - Queue(std::string Name,pkgAcquire *Owner); + Queue(std::string const &Name,pkgAcquire * const Owner); /** Shut down all the worker processes associated with this queue * and empty the queue. @@ -625,7 +625,7 @@ class pkgAcquire::UriIterator * * \param Q The queue over which this UriIterator should iterate. */ - UriIterator(pkgAcquire::Queue *Q); + explicit UriIterator(pkgAcquire::Queue *Q); virtual ~UriIterator(); }; /*}}}*/ diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index dab844220..9c9ceead4 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -67,7 +67,7 @@ class pkgSimulate : public pkgPackageManager /*{{{*/ return (*Cache)[Pkg].CandidateVerIter(*Cache); } - Policy(pkgDepCache *Cache) : Cache(Cache) {}; + explicit Policy(pkgDepCache *Cache) : Cache(Cache) {}; }; unsigned char *Flags; @@ -87,7 +87,7 @@ private: public: - pkgSimulate(pkgDepCache *Cache); + explicit pkgSimulate(pkgDepCache *Cache); virtual ~pkgSimulate(); }; /*}}}*/ @@ -155,7 +155,7 @@ class pkgProblemResolver /*{{{*/ APT_DEPRECATED void InstallProtect(); - pkgProblemResolver(pkgDepCache *Cache); + explicit pkgProblemResolver(pkgDepCache *Cache); virtual ~pkgProblemResolver(); }; /*}}}*/ diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h index b4697b773..df9e9460a 100644 --- a/apt-pkg/cachefilter.h +++ b/apt-pkg/cachefilter.h @@ -53,7 +53,7 @@ public: class NOTMatcher : public Matcher { Matcher * const matcher; public: - NOTMatcher(Matcher * const matcher); + explicit NOTMatcher(Matcher * const matcher); virtual bool operator() (pkgCache::PkgIterator const &Pkg); virtual bool operator() (pkgCache::GrpIterator const &Grp); virtual bool operator() (pkgCache::VerIterator const &Ver); @@ -65,7 +65,7 @@ class ANDMatcher : public Matcher { public: // 5 ought to be enough for everybody… c++11 variadic templates would be nice ANDMatcher(); - ANDMatcher(Matcher * const matcher1); + explicit ANDMatcher(Matcher * const matcher1); ANDMatcher(Matcher * const matcher1, Matcher * const matcher2); ANDMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3); ANDMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3, Matcher * const matcher4); @@ -81,7 +81,7 @@ class ORMatcher : public Matcher { public: // 5 ought to be enough for everybody… c++11 variadic templates would be nice ORMatcher(); - ORMatcher(Matcher * const matcher1); + explicit ORMatcher(Matcher * const matcher1); ORMatcher(Matcher * const matcher1, Matcher * const matcher2); ORMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3); ORMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3, Matcher * const matcher4); @@ -96,7 +96,7 @@ public: class PackageNameMatchesRegEx : public PackageMatcher { /*{{{*/ regex_t* pattern; public: - PackageNameMatchesRegEx(std::string const &Pattern); + explicit PackageNameMatchesRegEx(std::string const &Pattern); virtual bool operator() (pkgCache::PkgIterator const &Pkg); virtual bool operator() (pkgCache::GrpIterator const &Grp); virtual ~PackageNameMatchesRegEx(); @@ -105,7 +105,7 @@ public: class PackageNameMatchesFnmatch : public PackageMatcher { /*{{{*/ const std::string Pattern; public: - PackageNameMatchesFnmatch(std::string const &Pattern); + explicit PackageNameMatchesFnmatch(std::string const &Pattern); virtual bool operator() (pkgCache::PkgIterator const &Pkg); virtual bool operator() (pkgCache::GrpIterator const &Grp); virtual ~PackageNameMatchesFnmatch() {}; @@ -140,7 +140,7 @@ public: class PackageIsNewInstall : public PackageMatcher { /*{{{*/ pkgCacheFile * const Cache; public: - PackageIsNewInstall(pkgCacheFile * const Cache); + explicit PackageIsNewInstall(pkgCacheFile * const Cache); virtual bool operator() (pkgCache::PkgIterator const &Pkg); virtual ~PackageIsNewInstall(); }; diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 301da6fc4..f3b107699 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -107,7 +107,7 @@ class pkgCache::GrpIterator: public Iterator { public: // This constructor is the 'begin' constructor, never use it. - inline GrpIterator(pkgCache &Owner) : Iterator(Owner), HashIndex(-1) { + explicit inline GrpIterator(pkgCache &Owner) : Iterator(Owner), HashIndex(-1) { S = OwnerPointer(); operator ++(0); } @@ -148,7 +148,7 @@ class pkgCache::PkgIterator: public Iterator { public: // This constructor is the 'begin' constructor, never use it. - inline PkgIterator(pkgCache &Owner) : Iterator(Owner), HashIndex(-1) { + explicit inline PkgIterator(pkgCache &Owner) : Iterator(Owner), HashIndex(-1) { S = OwnerPointer(); operator ++(0); } @@ -394,7 +394,7 @@ class pkgCache::RlsFileIterator : public Iterator // Constructors inline RlsFileIterator() : Iterator() {} - inline RlsFileIterator(pkgCache &Owner) : Iterator(Owner, Owner.RlsFileP) {} + explicit inline RlsFileIterator(pkgCache &Owner) : Iterator(Owner, Owner.RlsFileP) {} inline RlsFileIterator(pkgCache &Owner,ReleaseFile *Trg) : Iterator(Owner, Trg) {} }; /*}}}*/ @@ -430,7 +430,7 @@ class pkgCache::PkgFileIterator : public Iterator // Constructors inline PkgFileIterator() : Iterator() {} - inline PkgFileIterator(pkgCache &Owner) : Iterator(Owner, Owner.PkgFileP) {} + explicit inline PkgFileIterator(pkgCache &Owner) : Iterator(Owner, Owner.PkgFileP) {} inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator(Owner, Trg) {} }; /*}}}*/ diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 1a6feb5f7..7fd740335 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -265,7 +265,7 @@ APT_IGNORE_DEPRECATED_POP void setConstructor(CacheSetHelper::PkgSelector const by) { ConstructedBy = by; } CacheSetHelper::PkgSelector getConstructor() const { return ConstructedBy; } PackageContainerInterface(); - PackageContainerInterface(CacheSetHelper::PkgSelector const by); + explicit PackageContainerInterface(CacheSetHelper::PkgSelector const by); virtual ~PackageContainerInterface(); APT_DEPRECATED static bool FromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) { @@ -310,7 +310,7 @@ public: /*{{{*/ public std::iterator { typename Container::const_iterator _iter; public: - const_iterator(typename Container::const_iterator i) : _iter(i) {} + explicit const_iterator(typename Container::const_iterator i) : _iter(i) {} pkgCache::PkgIterator getPkg(void) const { return *_iter; } inline pkgCache::PkgIterator operator*(void) const { return *_iter; } operator typename Container::const_iterator(void) const { return _iter; } @@ -324,7 +324,7 @@ public: /*{{{*/ public std::iterator { typename Container::iterator _iter; public: - iterator(typename Container::iterator i) : _iter(i) {} + explicit iterator(typename Container::iterator i) : _iter(i) {} pkgCache::PkgIterator getPkg(void) const { return *_iter; } inline pkgCache::PkgIterator operator*(void) const { return *_iter; } operator typename Container::iterator(void) const { return _iter; } @@ -359,7 +359,7 @@ public: /*{{{*/ const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); } PackageContainer() : PackageContainerInterface(CacheSetHelper::UNKNOWN) {} - PackageContainer(CacheSetHelper::PkgSelector const &by) : PackageContainerInterface(by) {} + explicit PackageContainer(CacheSetHelper::PkgSelector const &by) : PackageContainerInterface(by) {} APT_IGNORE_DEPRECATED_PUSH APT_DEPRECATED PackageContainer(Constructor const &by) : PackageContainerInterface((CacheSetHelper::PkgSelector)by) {} APT_IGNORE_DEPRECATED_POP @@ -568,7 +568,7 @@ public: APT_PUBLIC iterator begin() { return _cont->PkgBegin(); } APT_PUBLIC iterator end() { return _cont->PkgEnd(); } - APT_PUBLIC PackageUniverse(pkgCache * const Owner); + explicit APT_PUBLIC PackageUniverse(pkgCache * const Owner); APT_PUBLIC virtual ~PackageUniverse(); private: @@ -744,7 +744,7 @@ public: /*{{{*/ public std::iterator {/*{{{*/ typename Container::const_iterator _iter; public: - const_iterator(typename Container::const_iterator i) : _iter(i) {} + explicit const_iterator(typename Container::const_iterator i) : _iter(i) {} pkgCache::VerIterator getVer(void) const { return *_iter; } inline pkgCache::VerIterator operator*(void) const { return *_iter; } operator typename Container::const_iterator(void) const { return _iter; } @@ -758,7 +758,7 @@ public: /*{{{*/ public std::iterator { typename Container::iterator _iter; public: - iterator(typename Container::iterator i) : _iter(i) {} + explicit iterator(typename Container::iterator i) : _iter(i) {} pkgCache::VerIterator getVer(void) const { return *_iter; } inline pkgCache::VerIterator operator*(void) const { return *_iter; } operator typename Container::iterator(void) const { return _iter; } diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 46cf0ba08..05a137653 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -276,7 +276,7 @@ public: unsigned long long FileSize; unsigned int CalcHashes; - PrivateHashes(unsigned int const CalcHashes) : FileSize(0), CalcHashes(CalcHashes) {} + explicit PrivateHashes(unsigned int const CalcHashes) : FileSize(0), CalcHashes(CalcHashes) {} }; /*}}}*/ // Hashes::Add* - Add the contents of data or FD /*{{{*/ diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 869dc5cb7..d0ea0971e 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -87,7 +87,7 @@ class HashSumValue Sum[I] = S[I]; } - HashSumValue(std::string Str) + explicit HashSumValue(std::string const &Str) { memset(Sum,0,sizeof(Sum)); Set(Str); diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 5731b5a2b..05624f7fb 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1308,7 +1308,7 @@ void ioprintf(ostream &out,const char *format,...) va_list args; ssize_t size = 400; while (true) { - bool ret = false; + bool ret; va_start(args,format); ret = iovprintf(out, format, args, size); va_end(args); @@ -1322,7 +1322,7 @@ void strprintf(string &out,const char *format,...) ssize_t size = 400; std::ostringstream outstr; while (true) { - bool ret = false; + bool ret; va_start(args,format); ret = iovprintf(outstr, format, args, size); va_end(args); diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 34fc98838..430a5021b 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -103,7 +103,7 @@ debReleaseIndex::~debReleaseIndex() { } template -void foreachTarget(std::string const URI, std::string const Dist, +void foreachTarget(std::string const &URI, std::string const &Dist, std::map > const &ArchEntries, CallC &Call) { diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 36e1ac9ec..921cbced5 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -95,7 +95,9 @@ pkgDepCache::ActionGroup::~ActionGroup() // --------------------------------------------------------------------- /* */ pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) : - group_level(0), Cache(pCache), PkgState(0), DepState(0) + group_level(0), Cache(pCache), PkgState(0), DepState(0), + iUsrSize(0), iDownloadSize(0), iInstCount(0), iDelCount(0), iKeepCount(0), + iBrokenCount(0), iPolicyBrokenCount(0), iBadCount(0) { DebugMarker = _config->FindB("Debug::pkgDepCache::Marker", false); DebugAutoInstall = _config->FindB("Debug::pkgDepCache::AutoInstall", false); @@ -947,7 +949,7 @@ bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, /* */ struct CompareProviders { pkgCache::PkgIterator const Pkg; - CompareProviders(pkgCache::DepIterator const &Dep) : Pkg(Dep.TargetPkg()) {}; + explicit CompareProviders(pkgCache::DepIterator const &Dep) : Pkg(Dep.TargetPkg()) {}; //bool operator() (APT::VersionList::iterator const &AV, APT::VersionList::iterator const &BV) bool operator() (pkgCache::VerIterator const &AV, pkgCache::VerIterator const &BV) { diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 94c1088f2..0594a253d 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -179,7 +179,7 @@ class pkgDepCache : protected pkgCache::Namespace * As long as this object exists, no automatic cleanup * operations will be undertaken. */ - ActionGroup(pkgDepCache &cache); + explicit ActionGroup(pkgDepCache &cache); /** \brief Clean up the action group before it is destroyed. * diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 120d061ad..b0f191ded 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -424,7 +424,6 @@ bool PackageCopy::GetFile(string &File,unsigned long long &Size) // PackageCopy::RewriteEntry - Rewrite the entry with a new filename /*{{{*/ bool PackageCopy::RewriteEntry(FileFd &Target,string const &File) { - string const Dir(File,0,File.rfind('/')); std::vector Changes; Changes.push_back(pkgTagSection::Tag::Rewrite("Filename", File)); diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index c51879bb8..b6472e201 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -144,7 +144,7 @@ class pkgIndexFile bool IsTrusted() const { return Trusted; }; - pkgIndexFile(bool Trusted); + explicit pkgIndexFile(bool Trusted); virtual ~pkgIndexFile(); }; diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 7e6da9558..5a93d826f 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -42,7 +42,7 @@ APT_PURE bool indexRecords::GetSupportsAcquireByHash() const return this->SupportsAcquireByHash; } -APT_PURE bool indexRecords::CheckDist(const string MaybeDist) const +APT_PURE bool indexRecords::CheckDist(string const &MaybeDist) const { return (this->Dist == MaybeDist || this->Suite == MaybeDist); @@ -63,7 +63,7 @@ APT_PURE time_t indexRecords::GetDate() const return this->Date; } -APT_PURE indexRecords::checkSum *indexRecords::Lookup(const string MetaKey) +APT_PURE indexRecords::checkSum *indexRecords::Lookup(string const &MetaKey) { std::map::const_iterator sum = Entries.find(MetaKey); if (sum == Entries.end()) @@ -76,7 +76,7 @@ APT_PURE bool indexRecords::Exists(string const &MetaKey) const return Entries.find(MetaKey) != Entries.end(); } -bool indexRecords::Load(const string Filename) /*{{{*/ +bool indexRecords::Load(string const &Filename) /*{{{*/ { FileFd Fd; if (OpenMaybeClearSignedFile(Filename, Fd) == false) @@ -272,23 +272,10 @@ void indexRecords::SetTrusted(bool const Trusted) this->Trusted = NEVER_TRUSTED; } -#if APT_PKG_ABI >= 413 indexRecords::indexRecords(const string &ExpectedDist) : Trusted(CHECK_TRUST), d(NULL), ExpectedDist(ExpectedDist), ValidUntil(0), SupportsAcquireByHash(false) { } -#else -indexRecords::indexRecords() : - Trusted(CHECK_TRUST), d(NULL), ExpectedDist(""), ValidUntil(0), - SupportsAcquireByHash(false) -{ -} -indexRecords::indexRecords(const string ExpectedDist) : - Trusted(CHECK_TRUST), d(NULL), ExpectedDist(ExpectedDist), ValidUntil(0), - SupportsAcquireByHash(false) -{ -} -#endif indexRecords::~indexRecords() {} diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index f7dfa3235..3ff072590 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -40,21 +40,16 @@ class indexRecords std::map Entries; public: -#if APT_PKG_ABI >= 413 - indexRecords(const std::string &ExpectedDist = ""); -#else - indexRecords(); - indexRecords(const std::string ExpectedDist); -#endif + explicit indexRecords(const std::string &ExpectedDist = ""); // Lookup function - virtual checkSum *Lookup(const std::string MetaKey); + virtual checkSum *Lookup(std::string const &MetaKey); /** \brief tests if a checksum for this file is available */ bool Exists(std::string const &MetaKey) const; std::vector MetaKeys(); - virtual bool Load(std::string Filename); - virtual bool CheckDist(const std::string MaybeDist) const; + virtual bool Load(std::string const &Filename); + virtual bool CheckDist(std::string const &MaybeDist) const; std::string GetDist() const; std::string GetSuite() const; diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h index a4c5daf7f..5da3624c0 100644 --- a/apt-pkg/install-progress.h +++ b/apt-pkg/install-progress.h @@ -69,7 +69,7 @@ namespace Progress { void WriteToStatusFd(std::string msg); public: - PackageManagerProgressFd(int progress_fd); + explicit PackageManagerProgressFd(int progress_fd); virtual ~PackageManagerProgressFd(); virtual void StartDpkg(); @@ -100,7 +100,7 @@ namespace Progress { void WriteToStatusFd(std::string msg); public: - PackageManagerProgressDeb822Fd(int progress_fd); + explicit PackageManagerProgressDeb822Fd(int progress_fd); virtual ~PackageManagerProgressDeb822Fd(); virtual void StartDpkg(); diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index 29ef79b84..6d9f45eed 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -122,7 +122,7 @@ class pkgOrderList : protected pkgCache::Namespace int Score(PkgIterator Pkg); - pkgOrderList(pkgDepCache *Cache); + explicit pkgOrderList(pkgDepCache *Cache); virtual ~pkgOrderList(); }; diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 60414ae1c..2cdf92cdd 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -141,7 +141,7 @@ class pkgPackageManager : protected pkgCache::Namespace /** \brief returns all packages dpkg let disappear */ inline std::set GetDisappearedPackages() { return disappearedPkgs; }; - pkgPackageManager(pkgDepCache *Cache); + explicit pkgPackageManager(pkgDepCache *Cache); virtual ~pkgPackageManager(); private: diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 3c1a40972..c7b6de1b6 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -54,7 +54,7 @@ class APT_HIDDEN pkgCacheGenerator /*{{{*/ template class Dynamic { public: static std::vector toReMap; - Dynamic(Iter &I) { + explicit Dynamic(Iter &I) { toReMap.push_back(&I); } diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index 66eb17857..766e845aa 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -42,7 +42,7 @@ class pkgRecords /*{{{*/ Parser &Lookup(pkgCache::DescFileIterator const &Desc); // Construct destruct - pkgRecords(pkgCache &Cache); + explicit pkgRecords(pkgCache &Cache); virtual ~pkgRecords(); }; /*}}}*/ diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h index 4efe2ec50..0d2b468bc 100644 --- a/apt-pkg/policy.h +++ b/apt-pkg/policy.h @@ -59,7 +59,7 @@ class pkgPolicy : public pkgDepCache::Policy struct PkgPin : Pin { std::string Pkg; - PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {}; + explicit PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {}; }; Pin *Pins; @@ -85,7 +85,7 @@ class pkgPolicy : public pkgDepCache::Policy bool InitDefaults(); - pkgPolicy(pkgCache *Owner); + explicit pkgPolicy(pkgCache *Owner); virtual ~pkgPolicy(); private: pkgCache::VerIterator GetCandidateVerNew(pkgCache::PkgIterator const &Pkg); diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index c92643829..d9eacc08f 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -117,7 +117,7 @@ class pkgSourceList time_t GetLastModifiedTime(); pkgSourceList(); - pkgSourceList(std::string File); + explicit pkgSourceList(std::string File); virtual ~pkgSourceList(); }; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 3175ee75f..bbab9d796 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -178,3 +178,7 @@ bool pkgSrcRecords::Parser::Files2(std::vector &F2)/*{{{*/ return true; } /*}}}*/ + + +pkgSrcRecords::Parser::Parser(const pkgIndexFile *Index) : iIndex(Index) {} +pkgSrcRecords::Parser::~Parser() {} diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index dda66ce48..71173c953 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -48,6 +48,7 @@ APT_IGNORE_DEPRECATED_POP // Abstract parser for each source record class Parser { + void *d; protected: const pkgIndexFile *iIndex; @@ -85,9 +86,9 @@ APT_IGNORE_DEPRECATED_POP virtual bool Files(std::vector &F) = 0; bool Files2(std::vector &F); - - Parser(const pkgIndexFile *Index) : iIndex(Index) {}; - virtual ~Parser() {}; + + explicit Parser(const pkgIndexFile *Index); + virtual ~Parser(); }; private: @@ -110,8 +111,8 @@ APT_IGNORE_DEPRECATED_POP // Locate a package by name and return pointer to the Parser. // The pointer is owned by libapt. Parser* Find(const char *Package,bool const &SrcOnly = false); - - pkgSrcRecords(pkgSourceList &List); + + explicit pkgSrcRecords(pkgSourceList &List); virtual ~pkgSrcRecords(); }; diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 5ff495fbd..130aef19d 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -59,7 +59,7 @@ public: unsigned int StartValue; unsigned int NextInBucket; - TagData(unsigned int const StartTag) : StartTag(StartTag), EndTag(0), StartValue(0), NextInBucket(0) {} + explicit TagData(unsigned int const StartTag) : StartTag(StartTag), EndTag(0), StartValue(0), NextInBucket(0) {} }; std::vector Tags; }; diff --git a/cmdline/apt-extracttemplates.h b/cmdline/apt-extracttemplates.h index 829cdae75..b129a2d51 100644 --- a/cmdline/apt-extracttemplates.h +++ b/cmdline/apt-extracttemplates.h @@ -24,7 +24,7 @@ class DebFile : public pkgDirStream unsigned long ControlLen; public: - DebFile(const char *FileName); + explicit DebFile(const char *FileName); ~DebFile(); bool DoItem(Item &I, int &fd); bool Process(pkgDirStream::Item &I, const unsigned char *data,