Browse Source

apply various suggestions made by cppcheck

Reported-By: cppcheck
Git-Dch: Ignore
tags/debian/1.1_exp15
David Kalnischkies 6 years ago
parent
commit
258b9e512c
25 changed files with 35 additions and 45 deletions
  1. +1
    -1
      apt-inst/contrib/extracttar.cc
  2. +4
    -8
      apt-pkg/acquire-item.cc
  3. +1
    -1
      apt-pkg/algorithms.cc
  4. +1
    -1
      apt-pkg/deb/dpkgpm.cc
  5. +1
    -1
      apt-pkg/indexfile.h
  6. +0
    -1
      apt-pkg/pkgcachegen.cc
  7. +2
    -2
      apt-pkg/policy.cc
  8. +1
    -2
      apt-private/acqprogress.cc
  9. +1
    -1
      apt-private/private-cachefile.h
  10. +2
    -4
      apt-private/private-cacheset.cc
  11. +1
    -1
      apt-private/private-cacheset.h
  12. +1
    -1
      apt-private/private-install.cc
  13. +1
    -1
      apt-private/private-list.cc
  14. +1
    -1
      apt-private/private-show.cc
  15. +4
    -4
      ftparchive/apt-ftparchive.cc
  16. +1
    -1
      ftparchive/cachedb.h
  17. +1
    -1
      ftparchive/contents.cc
  18. +1
    -1
      methods/ftp.h
  19. +1
    -1
      methods/gzip.cc
  20. +1
    -1
      methods/http.h
  21. +2
    -2
      methods/https.cc
  22. +1
    -3
      methods/https.h
  23. +2
    -2
      methods/rred.cc
  24. +2
    -2
      methods/rsh.h
  25. +1
    -1
      test/libapt/acqprogress_test.cc

+ 1
- 1
apt-inst/contrib/extracttar.cc View File

@@ -101,7 +101,7 @@ bool ExtractTar::StartGzip()

std::vector<APT::Configuration::Compressor> const compressors = APT::Configuration::getCompressors();
std::vector<APT::Configuration::Compressor>::const_iterator compressor = compressors.begin();
for (; compressor != compressors.end(); compressor++) {
for (; compressor != compressors.end(); ++compressor) {
if (compressor->Name == DecompressProg) {
return InFd.OpenDescriptor(File.Fd(), FileFd::ReadOnly, *compressor, false);
}


+ 4
- 8
apt-pkg/acquire-item.cc View File

@@ -2237,14 +2237,10 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/

// remove all patches until the next matching patch is found
// this requires the Index file to be ordered
for(vector<DiffInfo>::iterator I = available_patches.begin();
available_patches.empty() == false &&
I != available_patches.end() &&
I->result_hashes != LocalHashes;
++I)
{
available_patches.erase(I);
}
available_patches.erase(available_patches.begin(),
std::find_if(available_patches.begin(), available_patches.end(), [&](DiffInfo const &I) {
return I.result_hashes == LocalHashes;
}));

// error checking and falling back if no patch was found
if(available_patches.empty() == true)


+ 1
- 1
apt-pkg/algorithms.cc View File

@@ -1315,7 +1315,7 @@ void pkgProblemResolver::InstallProtect()
struct PrioComp {
pkgCache &PrioCache;

PrioComp(pkgCache &PrioCache) : PrioCache(PrioCache) {
explicit PrioComp(pkgCache &PrioCache) : PrioCache(PrioCache) {
}

bool operator() (pkgCache::Version * const &A, pkgCache::Version * const &B) {


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

@@ -126,7 +126,7 @@ namespace
const char *target;

public:
MatchProcessingOp(const char *the_target)
explicit MatchProcessingOp(const char *the_target)
: target(the_target)
{
}


+ 1
- 1
apt-pkg/indexfile.h View File

@@ -168,7 +168,7 @@ public:
virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* const Prog) APT_OVERRIDE;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;

pkgDebianIndexFile(bool const Trusted);
explicit pkgDebianIndexFile(bool const Trusted);
virtual ~pkgDebianIndexFile();
};



+ 0
- 1
apt-pkg/pkgcachegen.cc View File

@@ -1434,7 +1434,6 @@ static bool BuildCache(pkgCacheGenerator &Gen,
pkgSourceList const * const List,
FileIterator const Start, FileIterator const End)
{
std::vector<pkgIndexFile *> Files;
bool mergeFailure = false;

auto const indexFileMerge = [&](pkgIndexFile * const I) {


+ 2
- 2
apt-pkg/policy.cc View File

@@ -235,7 +235,7 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVerNew(pkgCache::PkgIterator const
int candPriority = -1;
pkgVersioningSystem *vs = Cache->VS;

for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ver++) {
for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ++ver) {
int priority = GetPriority(ver, true);

if (priority == 0 || priority <= candPriority)
@@ -322,7 +322,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,

// Find matching version(s) and copy the pin into it
pkgVersionMatch Match(P->Data,P->Type);
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; Ver++)
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
{
if (Match.VersionMatches(Ver)) {
Pin *VP = VerPins + Ver->ID;


+ 1
- 2
apt-private/acqprogress.cc View File

@@ -176,8 +176,6 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
if (Quiet > 0)
return true;

enum {Long = 0,Medium,Short} Mode = Medium;

std::string Line;
{
std::stringstream S;
@@ -203,6 +201,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
if (I->CurrentItem->Owner->ActiveSubprocess.empty() == false)
S << " " << I->CurrentItem->Owner->ActiveSubprocess;

enum {Long = 0,Medium,Short} Mode = Medium;
// Add the current progress
if (Mode == Long)
S << " " << I->CurrentSize;


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

@@ -46,7 +46,7 @@ class SortedPackageUniverse : public APT::PackageUniverse
void LazyInit() const;

public:
SortedPackageUniverse(CacheFile &Cache);
explicit SortedPackageUniverse(CacheFile &Cache);

class const_iterator : public APT::Container_iterator_base<APT::PackageContainerInterface, SortedPackageUniverse, SortedPackageUniverse::const_iterator, std::vector<map_pointer_t>::const_iterator, pkgCache::PkgIterator>
{


+ 2
- 4
apt-private/private-cacheset.cc View File

@@ -179,8 +179,8 @@ CacheSetHelperVirtuals::CacheSetHelperVirtuals(bool const ShowErrors, GlobalErro
/*}}}*/

// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
CacheSetHelperAPTGet::CacheSetHelperAPTGet(std::ostream &out) :
APT::CacheSetHelper{true}, out(out)
CacheSetHelperAPTGet::CacheSetHelperAPTGet(std::ostream &pout) :
APT::CacheSetHelper{true}, out(pout)
{
explicitlyNamed = true;
}
@@ -245,8 +245,6 @@ bool CacheSetHelperAPTGet::showVirtualPackageErrors(pkgCacheFile &Cache)
"This may mean that the package is missing, has been obsoleted, or\n"
"is only available from another source\n"),Pkg.FullName(true).c_str());

std::string List;
std::string VersionsList;
std::vector<bool> Seen(Cache.GetPkgCache()->Head().PackageCount, false);
APT::PackageList pkglist;
for (pkgCache::DepIterator Dep = Pkg.RevDependsList();


+ 1
- 1
apt-private/private-cacheset.h View File

@@ -89,7 +89,7 @@ class APT_PUBLIC CacheSetHelperAPTGet : public APT::CacheSetHelper {
public:
std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;

CacheSetHelperAPTGet(std::ostream &out);
explicit CacheSetHelperAPTGet(std::ostream &out);

virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;


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

@@ -666,7 +666,7 @@ struct PkgIsExtraInstalled {
pkgCacheFile * const Cache;
APT::VersionSet const * const verset;
PkgIsExtraInstalled(pkgCacheFile * const Cache, APT::VersionSet const * const Container) : Cache(Cache), verset(Container) {}
bool operator() (pkgCache::PkgIterator const Pkg)
bool operator() (pkgCache::PkgIterator const &Pkg)
{
if ((*Cache)[Pkg].Install() == false)
return false;


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

@@ -41,7 +41,7 @@ struct PackageSortAlphabetic /*{{{*/
class PackageNameMatcher : public Matcher
{
public:
PackageNameMatcher(const char **patterns)
explicit PackageNameMatcher(const char **patterns)
{
for(int i=0; patterns[i] != NULL; ++i)
{


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

@@ -396,7 +396,7 @@ bool Policy(CommandLine &CmdL)
continue;
}
// New code
for (pkgCache::VerIterator V = I.VersionList(); !V.end(); V++) {
for (pkgCache::VerIterator V = I.VersionList(); !V.end(); ++V) {
auto Prio = Plcy->GetPriority(V, false);
if (Prio == 0)
continue;


+ 4
- 4
ftparchive/apt-ftparchive.cc View File

@@ -819,12 +819,12 @@ static bool DoGeneratePackagesAndSources(Configuration &Setup,
_error->DumpErrors();
// Do the generation for Packages
for (End = List; End->Str != 0; End++)
for (End = List; End->Str != 0; ++End)
{
if (End->Hit == false)
continue;
PackageMap *I = (PackageMap *)End->UserData;
PackageMap * const I = static_cast<PackageMap *>(End->UserData);
if (I->PkgDone == true)
continue;
if (I->GenPackages(Setup,Stats) == false)
@@ -832,12 +832,12 @@ static bool DoGeneratePackagesAndSources(Configuration &Setup,
}
// Do the generation for Sources
for (End = List; End->Str != 0; End++)
for (End = List; End->Str != 0; ++End)
{
if (End->Hit == false)
continue;
PackageMap *I = (PackageMap *)End->UserData;
PackageMap * const I = static_cast<PackageMap *>(End->UserData);
if (I->SrcDone == true)
continue;
if (I->GenSources(Setup,SrcStats) == false)


+ 1
- 1
ftparchive/cachedb.h View File

@@ -189,7 +189,7 @@ class CacheDB
bool Clean();
CacheDB(std::string const &DB);
explicit CacheDB(std::string const &DB);
~CacheDB();
};


+ 1
- 1
ftparchive/contents.cc View File

@@ -100,7 +100,7 @@ void *GenContents::Node::operator new(size_t Amount,GenContents *Owner)
if (Owner->NodeLeft == 0)
{
Owner->NodeLeft = 10000;
Owner->NodePool = (Node *)malloc(Amount*Owner->NodeLeft);
Owner->NodePool = static_cast<Node *>(malloc(Amount*Owner->NodeLeft));
BigBlock *Block = new BigBlock;
Block->Block = Owner->NodePool;
Block->Next = Owner->BlockList;


+ 1
- 1
methods/ftp.h View File

@@ -68,7 +68,7 @@ class FTPConn
Hashes &MD5,bool &Missing, unsigned long long MaximumSize,
pkgAcqMethod *Owner);
FTPConn(URI Srv);
explicit FTPConn(URI Srv);
~FTPConn();
};



+ 1
- 1
methods/gzip.cc View File

@@ -36,7 +36,7 @@ class GzipMethod : public aptMethod

public:

GzipMethod(std::string const &pProg) : aptMethod(pProg.c_str(),"1.1",SingleInstance | SendConfig), Prog(pProg) {};
explicit GzipMethod(std::string const &pProg) : aptMethod(pProg.c_str(),"1.1",SingleInstance | SendConfig), Prog(pProg) {};
};

// GzipMethod::Fetch - Decompress the passed URI /*{{{*/


+ 1
- 1
methods/http.h View File

@@ -87,7 +87,7 @@ class CircleBuf
// Dump everything
void Stats();

CircleBuf(unsigned long long Size);
explicit CircleBuf(unsigned long long Size);
~CircleBuf();
};



+ 2
- 2
methods/https.cc View File

@@ -49,7 +49,7 @@ size_t
HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp)
{
size_t len = size * nmemb;
CURLUserPointer *me = (CURLUserPointer *)userp;
CURLUserPointer *me = static_cast<CURLUserPointer *>(userp);
std::string line((char*) buffer, len);
for (--len; len > 0; --len)
if (isspace(line[len]) == 0)
@@ -115,7 +115,7 @@ HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp)
size_t
HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp)
{
HttpsMethod *me = (HttpsMethod *)userp;
HttpsMethod *me = static_cast<HttpsMethod *>(userp);
size_t buffer_size = size * nmemb;
// we don't need to count the junk here, just drop anything we get as
// we don't always know how long it would be, e.g. in chunked encoding.


+ 1
- 3
methods/https.h View File

@@ -68,21 +68,19 @@ class HttpsMethod : public ServerMethod
double ultotal, double ulnow);
void SetupProxy();
CURL *curl;
std::unique_ptr<ServerState> Server;

// Used by ServerMethods unused by https
virtual void SendReq(FetchItem *) APT_OVERRIDE { exit(42); }
virtual void RotateDNS() APT_OVERRIDE { exit(42); }

public:
FileFd *File;

virtual bool Configuration(std::string Message) APT_OVERRIDE;
virtual std::unique_ptr<ServerState> CreateServerState(URI const &uri) APT_OVERRIDE;
using pkgAcqMethod::FetchResult;
using pkgAcqMethod::FetchItem;

HttpsMethod() : ServerMethod("https","1.2",Pipeline | SendConfig), File(NULL)
HttpsMethod() : ServerMethod("https","1.2",Pipeline | SendConfig)
{
curl = curl_easy_init();
};


+ 2
- 2
methods/rred.cc View File

@@ -39,7 +39,7 @@ class MemBlock {
char *free;
MemBlock *next;

MemBlock(size_t size) : size(size), next(NULL)
explicit MemBlock(size_t size) : size(size), next(NULL)
{
free = start = new char[size];
}
@@ -118,7 +118,7 @@ struct Change {
size_t add_len; /* bytes */
char *add;

Change(size_t off)
explicit Change(size_t off)
{
offset = off;
del_cnt = add_cnt = add_len = 0;


+ 2
- 2
methods/rsh.h View File

@@ -49,7 +49,7 @@ class RSHConn
bool Get(const char *Path,FileFd &To,unsigned long long Resume,
Hashes &Hash,bool &Missing, unsigned long long Size);

RSHConn(URI Srv);
explicit RSHConn(URI Srv);
~RSHConn();
};

@@ -71,7 +71,7 @@ class RSHMethod : public aptMethod

public:

RSHMethod(std::string const &Prog);
explicit RSHMethod(std::string const &Prog);
};

#endif

+ 1
- 1
test/libapt/acqprogress_test.cc View File

@@ -11,7 +11,7 @@
class TestItem: public pkgAcquire::Item
{
public:
TestItem(pkgAcquire * const Acq) : pkgAcquire::Item(Acq) {}
explicit TestItem(pkgAcquire * const Acq) : pkgAcquire::Item(Acq) {}

virtual std::string DescURI() const APT_OVERRIDE { return ""; }
virtual HashStringList GetExpectedHashes() const APT_OVERRIDE { return HashStringList(); }


Loading…
Cancel
Save