Browse Source

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
tags/devuan/2.0.1+devuan1
Julian Andres Klode 1 year ago
parent
commit
b52c6552c4
19 changed files with 34 additions and 32 deletions
  1. +1
    -1
      apt-inst/contrib/arfile.h
  2. +2
    -2
      apt-inst/deb/debfile.h
  3. +2
    -2
      apt-inst/filelist.h
  4. +2
    -2
      apt-pkg/contrib/configuration.h
  5. +1
    -1
      apt-pkg/contrib/fileutl.cc
  6. +1
    -1
      apt-pkg/contrib/mmap.h
  7. +2
    -2
      apt-pkg/contrib/progress.h
  8. +5
    -5
      apt-pkg/deb/debindexfile.h
  9. +3
    -3
      apt-pkg/deb/deblistparser.h
  10. +1
    -1
      apt-pkg/deb/debmetaindex.cc
  11. +1
    -1
      apt-pkg/deb/debrecords.h
  12. +1
    -1
      apt-pkg/deb/dpkgpm.h
  13. +3
    -3
      apt-pkg/edsp/edspindexfile.h
  14. +3
    -3
      apt-pkg/edsp/edsplistparser.h
  15. +1
    -1
      apt-pkg/edsp/edspsystem.h
  16. +2
    -0
      apt-private/private-cacheset.h
  17. +1
    -1
      apt-private/private-json-hooks.cc
  18. +1
    -1
      apt-private/private-sources.cc
  19. +1
    -1
      methods/mirror.cc

+ 1
- 1
apt-inst/contrib/arfile.h View File

@@ -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();
};



+ 2
- 2
apt-inst/deb/debfile.h View File

@@ -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;};
};
/*}}}*/


+ 2
- 2
apt-inst/filelist.h View File

@@ -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) {}
};


+ 2
- 2
apt-pkg/contrib/configuration.h View File

@@ -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 */


+ 1
- 1
apt-pkg/contrib/fileutl.cc View File

@@ -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)


+ 1
- 1
apt-pkg/contrib/mmap.h View File

@@ -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();
};



+ 2
- 2
apt-pkg/contrib/progress.h View File

@@ -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();};
};



+ 5
- 5
apt-pkg/deb/debindexfile.h View File

@@ -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

+ 3
- 3
apt-pkg/deb/deblistparser.h View File

@@ -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

+ 1
- 1
apt-pkg/deb/debmetaindex.cc View File

@@ -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 /*{{{*/


+ 1
- 1
apt-pkg/deb/debrecords.h View File

@@ -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();
};



+ 1
- 1
apt-pkg/deb/dpkgpm.h View File

@@ -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);


+ 3
- 3
apt-pkg/edsp/edspindexfile.h View File

@@ -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();
};



+ 3
- 3
apt-pkg/edsp/edsplistparser.h View File

@@ -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

+ 1
- 1
apt-pkg/edsp/edspsystem.h View File

@@ -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();
};



+ 2
- 0
apt-private/private-cacheset.h View File

@@ -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


+ 1
- 1
apt-private/private-json-hooks.cc View File

@@ -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()
{


+ 1
- 1
apt-private/private-sources.cc View File

@@ -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)


+ 1
- 1
methods/mirror.cc View File

@@ -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;
}


Loading…
Cancel
Save