summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-04-30 12:07:07 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2019-04-30 17:43:31 +0200
commitb52c6552c44fcb997b0db9f5e9f17b4674dd5359 (patch)
tree711f7259a65f5b658cb5ad4798323c2226cfb7c2
parent4fa03143eee3776e2fa8fbd59d3cbaea40be0871 (diff)
Add 'explicit' to most single argument constructors
This prevents implicit conversions that we do not want, such as having a FileFd* being converted to a debListParser. Two cases are not yet handled because they require changes in code using them: 1. The classes in hashes.h 2. The URI class - this one is used quite a lot
-rw-r--r--apt-inst/contrib/arfile.h2
-rw-r--r--apt-inst/deb/debfile.h4
-rw-r--r--apt-inst/filelist.h4
-rw-r--r--apt-pkg/contrib/configuration.h4
-rw-r--r--apt-pkg/contrib/fileutl.cc2
-rw-r--r--apt-pkg/contrib/mmap.h2
-rw-r--r--apt-pkg/contrib/progress.h4
-rw-r--r--apt-pkg/deb/debindexfile.h10
-rw-r--r--apt-pkg/deb/deblistparser.h6
-rw-r--r--apt-pkg/deb/debmetaindex.cc2
-rw-r--r--apt-pkg/deb/debrecords.h2
-rw-r--r--apt-pkg/deb/dpkgpm.h2
-rw-r--r--apt-pkg/edsp/edspindexfile.h6
-rw-r--r--apt-pkg/edsp/edsplistparser.h6
-rw-r--r--apt-pkg/edsp/edspsystem.h2
-rw-r--r--apt-private/private-cacheset.h2
-rw-r--r--apt-private/private-json-hooks.cc2
-rw-r--r--apt-private/private-sources.cc2
-rw-r--r--methods/mirror.cc2
19 files changed, 34 insertions, 32 deletions
diff --git a/apt-inst/contrib/arfile.h b/apt-inst/contrib/arfile.h
index 8124208c9..cf454941e 100644
--- a/apt-inst/contrib/arfile.h
+++ b/apt-inst/contrib/arfile.h
@@ -44,7 +44,7 @@ class ARArchive
const Member *FindMember(const char *Name) const;
inline Member *Members() { return List; }
- ARArchive(FileFd &File);
+ explicit ARArchive(FileFd &File);
~ARArchive();
};
diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h
index 23a76bfdf..21c59a567 100644
--- a/apt-inst/deb/debfile.h
+++ b/apt-inst/deb/debfile.h
@@ -56,7 +56,7 @@ class debDebFile
const ARArchive::Member *GotoMember(const char *Name);
inline FileFd &GetFile() {return File;};
- debDebFile(FileFd &File);
+ explicit debDebFile(FileFd &File);
};
class debDebFile::ControlExtract : public pkgDirStream
@@ -87,7 +87,7 @@ class debDebFile::MemControlExtract : public pkgDirStream
bool TakeControl(const void *Data,unsigned long long Size);
MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
- MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
+ explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
~MemControlExtract() {delete [] Control;};
};
/*}}}*/
diff --git a/apt-inst/filelist.h b/apt-inst/filelist.h
index 7fe43de63..c5f103d87 100644
--- a/apt-inst/filelist.h
+++ b/apt-inst/filelist.h
@@ -97,7 +97,7 @@ class pkgFLCache
bool AddConfFile(const char *Name,const char *NameEnd,
PkgIterator const &Owner,const unsigned char *Sum);
- pkgFLCache(DynamicMMap &Map);
+ explicit pkgFLCache(DynamicMMap &Map);
// ~pkgFLCache();
};
@@ -288,7 +288,7 @@ class pkgFLCache::NodeIterator
Package *RealPackage() const;
NodeIterator() : Nde(0), Type(NdeHash), Owner(0) {};
- NodeIterator(pkgFLCache &Owner) : Nde(Owner.NodeP), Type(NdeHash), Owner(&Owner) {}
+ explicit NodeIterator(pkgFLCache &Owner) : Nde(Owner.NodeP), Type(NdeHash), Owner(&Owner) {}
NodeIterator(pkgFLCache &Owner,Node *Trg) : Nde(Trg), Type(NdeHash), Owner(&Owner) {}
NodeIterator(pkgFLCache &Owner,Node *Trg,Package *) : Nde(Trg), Type(NdePkg), Owner(&Owner) {}
};
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 2a3ae1aa4..b5dfe721f 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -119,7 +119,7 @@ class Configuration
void Dump(std::ostream& str, char const * const root,
char const * const format, bool const emptyValue);
- Configuration(const Item *Root);
+ explicit Configuration(const Item *Root);
Configuration();
~Configuration();
@@ -130,7 +130,7 @@ class Configuration
APT_HIDDEN void clearPatterns();
public:
- MatchAgainstConfig(char const * Config);
+ explicit MatchAgainstConfig(char const * Config);
virtual ~MatchAgainstConfig();
/** \brief Returns \b true for a string matching one of the patterns */
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 3b4a4a10c..8d6cb3146 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1944,7 +1944,7 @@ class APT_HIDDEN LzmaFileFdPrivate: public FileFdPrivate { /*{{{*/
bool eof;
bool compressing;
- LZMAFILE(FileFd * const fd) : file(nullptr), filefd(fd), eof(false), compressing(false) { buffer[0] = '\0'; }
+ explicit LZMAFILE(FileFd * const fd) : file(nullptr), filefd(fd), eof(false), compressing(false) { buffer[0] = '\0'; }
~LZMAFILE()
{
if (compressing == true && filefd->Failed() == false)
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 63d54d27c..3af1f47fb 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -74,7 +74,7 @@ class MMap
bool Sync(unsigned long Start,unsigned long Stop);
MMap(FileFd &F,unsigned long Flags);
- MMap(unsigned long Flags);
+ explicit MMap(unsigned long Flags);
virtual ~MMap();
};
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index 4406a388b..903e6613e 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -80,9 +80,9 @@ class OpTextProgress : public OpProgress
virtual void Done() APT_OVERRIDE;
- OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate),
+ explicit OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate),
NoDisplay(false), LastLen(0) {};
- OpTextProgress(Configuration &Config);
+ explicit OpTextProgress(Configuration &Config);
virtual ~OpTextProgress() {Done();};
};
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 5c89f9c54..222fed229 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -44,7 +44,7 @@ public:
virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
- debStatusIndex(std::string const &File);
+ explicit debStatusIndex(std::string const &File);
virtual ~debStatusIndex();
};
@@ -83,7 +83,7 @@ public:
// Interface for the Cache Generator
virtual bool HasPackages() const APT_OVERRIDE;
- debTranslationsIndex(IndexTarget const &Target);
+ explicit debTranslationsIndex(IndexTarget const &Target);
virtual ~debTranslationsIndex();
};
@@ -141,7 +141,7 @@ public:
// Interface for acquire
- debDebPkgFileIndex(std::string const &DebFile);
+ explicit debDebPkgFileIndex(std::string const &DebFile);
virtual ~debDebPkgFileIndex();
//FIXME: use proper virtual-handling on next ABI break
@@ -162,7 +162,7 @@ public:
virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
virtual bool HasPackages() const APT_OVERRIDE {return false;};
- debDscFileIndex(std::string const &DscFile);
+ explicit debDscFileIndex(std::string const &DscFile);
virtual ~debDscFileIndex();
};
@@ -191,7 +191,7 @@ public:
// Abort if the file does not exist.
virtual bool Exists() const APT_OVERRIDE {return true;};
- debStringPackageIndex(std::string const &content);
+ explicit debStringPackageIndex(std::string const &content);
virtual ~debStringPackageIndex();
};
#endif
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index f02252d58..ad2b947fe 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -121,7 +121,7 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
- debListParser(FileFd *File);
+ explicit debListParser(FileFd *File);
virtual ~debListParser();
};
@@ -145,7 +145,7 @@ class APT_HIDDEN debTranslationsParser : public debListParser
virtual APT::StringView Version() APT_OVERRIDE { return ""; }
#endif
- debTranslationsParser(FileFd *File)
+ explicit debTranslationsParser(FileFd *File)
: debListParser(File) {};
};
@@ -153,7 +153,7 @@ class APT_HIDDEN debStatusListParser : public debListParser
{
public:
virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
- debStatusListParser(FileFd *File)
+ explicit debStatusListParser(FileFd *File)
: debListParser(File) {};
};
#endif
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index f2a6b97ad..13575e10b 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -109,7 +109,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/
std::vector<std::string> SupportedComponents;
std::map<std::string, std::string> const ReleaseOptions;
- debReleaseIndexPrivate(std::map<std::string, std::string> const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), CheckDate(metaIndex::TRI_UNSET), DateMaxFuture(0), NotBefore(0), ReleaseOptions(Options) {}
+ explicit debReleaseIndexPrivate(std::map<std::string, std::string> const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), CheckDate(metaIndex::TRI_UNSET), DateMaxFuture(0), NotBefore(0), ReleaseOptions(Options) {}
};
/*}}}*/
// ReleaseIndex::MetaIndex* - display helpers /*{{{*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index 7c3b9020c..ea3fc320a 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -85,7 +85,7 @@ class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase
public:
virtual std::string FileName() APT_OVERRIDE;
- debDebFileRecordParser(std::string FileName);
+ explicit debDebFileRecordParser(std::string FileName);
virtual ~debDebFileRecordParser();
};
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index 67c141766..3ba4770e8 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -131,7 +131,7 @@ class pkgDPkgPM : public pkgPackageManager
public:
- pkgDPkgPM(pkgDepCache *Cache);
+ explicit pkgDPkgPM(pkgDepCache *Cache);
virtual ~pkgDPkgPM();
APT_HIDDEN static bool ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache);
diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h
index 4ac0f9d72..8fa8fdd60 100644
--- a/apt-pkg/edsp/edspindexfile.h
+++ b/apt-pkg/edsp/edspindexfile.h
@@ -29,7 +29,7 @@ public:
virtual bool Exists() const APT_OVERRIDE;
virtual bool HasPackages() const APT_OVERRIDE;
- edspLikeIndex(std::string const &File);
+ explicit edspLikeIndex(std::string const &File);
virtual ~edspLikeIndex();
};
@@ -42,7 +42,7 @@ protected:
public:
virtual const Type *GetType() const APT_OVERRIDE APT_PURE;
- edspIndex(std::string const &File);
+ explicit edspIndex(std::string const &File);
virtual ~edspIndex();
};
@@ -55,7 +55,7 @@ protected:
public:
virtual const Type *GetType() const APT_OVERRIDE APT_PURE;
- eippIndex(std::string const &File);
+ explicit eippIndex(std::string const &File);
virtual ~eippIndex();
};
diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h
index 59c759f9d..8f56f8abf 100644
--- a/apt-pkg/edsp/edsplistparser.h
+++ b/apt-pkg/edsp/edsplistparser.h
@@ -35,7 +35,7 @@ class APT_HIDDEN edspLikeListParser : public debListParser
virtual APT::StringView Description_md5() APT_OVERRIDE;
virtual unsigned short VersionHash() APT_OVERRIDE;
- edspLikeListParser(FileFd *File);
+ explicit edspLikeListParser(FileFd *File);
virtual ~edspLikeListParser();
};
@@ -48,7 +48,7 @@ protected:
virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE;
public:
- edspListParser(FileFd *File);
+ explicit edspListParser(FileFd *File);
virtual ~edspListParser();
};
@@ -58,7 +58,7 @@ protected:
virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE;
public:
- eippListParser(FileFd *File);
+ explicit eippListParser(FileFd *File);
virtual ~eippListParser();
};
#endif
diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h
index 0855bb53f..8f5452dcb 100644
--- a/apt-pkg/edsp/edspsystem.h
+++ b/apt-pkg/edsp/edspsystem.h
@@ -37,7 +37,7 @@ public:
virtual bool FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const APT_OVERRIDE;
- edspLikeSystem(char const * const Label);
+ explicit edspLikeSystem(char const * const Label);
virtual ~edspLikeSystem();
};
diff --git a/apt-private/private-cacheset.h b/apt-private/private-cacheset.h
index 3370bd03a..c52df36d7 100644
--- a/apt-private/private-cacheset.h
+++ b/apt-private/private-cacheset.h
@@ -18,6 +18,8 @@ class VerIteratorWithCaching
const pkgCache::VerIterator iter;
const pkgCache::DescFile * descFile;
public:
+
+ // cppcheck-suppress noExplicitConstructor
VerIteratorWithCaching(const pkgCache::VerIterator& iter) :
iter(iter),
descFile(iter->DescriptionList != 0
diff --git a/apt-private/private-json-hooks.cc b/apt-private/private-json-hooks.cc
index 65ff87924..3e0d8c93b 100644
--- a/apt-private/private-json-hooks.cc
+++ b/apt-private/private-json-hooks.cc
@@ -79,7 +79,7 @@ class APT_HIDDEN JsonWriter
}
public:
- JsonWriter(std::ostream &os) : os(os) { old_locale = os.imbue(std::locale::classic()); }
+ explicit JsonWriter(std::ostream &os) : os(os) { old_locale = os.imbue(std::locale::classic()); }
~JsonWriter() { os.imbue(old_locale); }
JsonWriter &beginArray()
{
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc
index 713327f02..4cfb87938 100644
--- a/apt-private/private-sources.cc
+++ b/apt-private/private-sources.cc
@@ -31,7 +31,7 @@
class APT_HIDDEN ScopedGetLock {
public:
int fd;
- ScopedGetLock(std::string const &filename) : fd(GetLock(filename)) {}
+ explicit ScopedGetLock(std::string const &filename) : fd(GetLock(filename)) {}
~ScopedGetLock() { close(fd); }
};
bool EditSources(CommandLine &CmdL)
diff --git a/methods/mirror.cc b/methods/mirror.cc
index add9f0875..dcf4cbd13 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -97,7 +97,7 @@ class MirrorMethod : public aptMethod /*{{{*/
void DealWithPendingItems(std::vector<std::string> const &baseuris, MirrorListInfo const &info, FetchItem *const Itm, std::function<void()> handler);
public:
- MirrorMethod(std::string &&pProg) : aptMethod(std::move(pProg), "2.0", SingleInstance | Pipeline | SendConfig | AuxRequests), genrng(clock())
+ explicit MirrorMethod(std::string &&pProg) : aptMethod(std::move(pProg), "2.0", SingleInstance | Pipeline | SendConfig | AuxRequests), genrng(clock())
{
SeccompFlags = aptMethod::BASE | aptMethod::DIRECTORY;
}