From f14be456322a2c7310488c8a4bdec1d06fcf0e8d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 13 Mar 2012 13:52:28 +0100 Subject: cherry pick 2217.1.26 (cppcheck fixes) --- apt-pkg/acquire.cc | 2 +- apt-pkg/algorithms.cc | 2 +- apt-pkg/cachefile.cc | 2 +- apt-pkg/cachefilter.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 4 +++- apt-pkg/orderlist.cc | 14 ++++++-------- apt-pkg/packagemanager.cc | 11 +++++------ apt-pkg/pkgrecords.cc | 2 +- apt-pkg/pkgsystem.cc | 4 ++-- apt-pkg/sourcelist.cc | 2 +- apt-pkg/srcrecords.cc | 2 +- apt-pkg/tagfile.cc | 5 ++++- apt-pkg/version.cc | 4 ++-- cmdline/acqprogress.cc | 3 ++- cmdline/apt-extracttemplates.cc | 4 ++-- ftparchive/cachedb.h | 5 +++-- methods/ftp.cc | 1 + methods/http.h | 7 ++++--- methods/rsh.cc | 4 +++- 19 files changed, 44 insertions(+), 36 deletions(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index cdc3fba4b..573a85c2f 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -766,7 +766,7 @@ void pkgAcquire::Queue::Bump() // AcquireStatus::pkgAcquireStatus - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgAcquireStatus::pkgAcquireStatus() : Update(true), MorePulses(false) +pkgAcquireStatus::pkgAcquireStatus() : d(NULL), Update(true), MorePulses(false) { Start(); } diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index c337ace87..ed3534f0d 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -471,7 +471,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) // ProblemResolver::pkgProblemResolver - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : Cache(*pCache) +pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : d(NULL), Cache(*pCache) { // Allocate memory unsigned long Size = Cache.Head().PackageCount; diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 1b8d91a44..dfbd8b1d8 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -30,7 +30,7 @@ // CacheFile::CacheFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgCacheFile::pkgCacheFile() : Map(NULL), Cache(NULL), DCache(NULL), +pkgCacheFile::pkgCacheFile() : d(NULL), Map(NULL), Cache(NULL), DCache(NULL), SrcList(NULL), Policy(NULL) { } diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc index 210a9a9ab..9ec3fa699 100644 --- a/apt-pkg/cachefilter.cc +++ b/apt-pkg/cachefilter.cc @@ -18,7 +18,7 @@ /*}}}*/ namespace APT { namespace CacheFilter { -PackageNameMatchesRegEx::PackageNameMatchesRegEx(std::string const &Pattern) {/*{{{*/ +PackageNameMatchesRegEx::PackageNameMatchesRegEx(std::string const &Pattern) : d(NULL) {/*{{{*/ pattern = new regex_t; int const Res = regcomp(pattern, Pattern.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB); if (Res == 0) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d28461dab..eb43cbfb8 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -50,8 +50,10 @@ using namespace std; class pkgDPkgPMPrivate { public: - pkgDPkgPMPrivate() : dpkgbuf_pos(0), term_out(NULL), history_out(NULL) + pkgDPkgPMPrivate() : stdin_is_dev_null(false), dpkgbuf_pos(0), + term_out(NULL), history_out(NULL) { + dpkgbuf[0] = '\0'; } bool stdin_is_dev_null; // the buffer we use for the dpkg status-fd reading diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 0ac9a83e3..3a179b2a2 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -82,16 +82,14 @@ pkgOrderList *pkgOrderList::Me = 0; // OrderList::pkgOrderList - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgOrderList::pkgOrderList(pkgDepCache *pCache) : Cache(*pCache) +pkgOrderList::pkgOrderList(pkgDepCache *pCache) : Cache(*pCache), + Primary(NULL), Secondary(NULL), + RevDepends(NULL), Remove(NULL), + AfterEnd(NULL), FileList(NULL), + LoopCount(-1), Depth(0) { - FileList = 0; - Primary = 0; - Secondary = 0; - RevDepends = 0; - Remove = 0; - LoopCount = -1; Debug = _config->FindB("Debug::pkgOrderList",false); - + /* Construct the arrays, egcs 1.0.1 bug requires the package count hack */ unsigned long Size = Cache.Head().PackageCount; diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 3f5b8c8ff..d55baabcf 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -36,11 +36,13 @@ bool pkgPackageManager::SigINTStop = false; // PM::PackageManager - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache) +pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache), + List(NULL), Res(Incomplete) { FileNames = new string[Cache.Head().PackageCount]; - List = 0; Debug = _config->FindB("Debug::pkgPackageManager",false); + NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); + ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false); } /*}}}*/ // PM::PackageManager - Destructor /*{{{*/ @@ -169,10 +171,7 @@ bool pkgPackageManager::CreateOrderList() delete List; List = new pkgOrderList(&Cache); - - NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); - ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false); - + if (Debug && ImmConfigureAll) clog << "CreateOrderList(): Adding Immediate flag for all packages because of APT::Immediate-Configure-All" << endl; diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index c5b3bebd7..36dab3480 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -22,7 +22,7 @@ // Records::pkgRecords - Constructor /*{{{*/ // --------------------------------------------------------------------- /* This will create the necessary structures to access the status files */ -pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), +pkgRecords::pkgRecords(pkgCache &Cache) : d(NULL), Cache(Cache), Files(Cache.HeaderP->PackageFileCount) { for (pkgCache::PkgFileIterator I = Cache.FileBegin(); diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc index f61c140fa..05ba6e0e6 100644 --- a/apt-pkg/pkgsystem.cc +++ b/apt-pkg/pkgsystem.cc @@ -26,11 +26,11 @@ unsigned long pkgSystem::GlobalListLen = 0; // System::pkgSystem - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Add it to the global list.. */ -pkgSystem::pkgSystem() +pkgSystem::pkgSystem() : Label(NULL), VS(NULL) { assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList)); SysList[GlobalListLen] = this; - GlobalListLen++; + ++GlobalListLen; } /*}}}*/ // System::GetSystem - Get the named system /*{{{*/ diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index f5f458099..0fddfb451 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -33,7 +33,7 @@ unsigned long pkgSourceList::Type::GlobalListLen = 0; // Type::Type - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Link this to the global list of items*/ -pkgSourceList::Type::Type() +pkgSourceList::Type::Type() : Name(NULL), Label(NULL) { ItmList[GlobalListLen] = this; GlobalListLen++; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 48b643eac..d63d2c422 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -25,7 +25,7 @@ // SrcRecords::pkgSrcRecords - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Open all the source index files */ -pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0) +pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : d(NULL), Files(0), Current(0) { for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); ++I) { diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index ec86173df..79811899a 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -30,7 +30,10 @@ using std::string; class pkgTagFilePrivate { public: - pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Size(Size) + pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Buffer(NULL), + Start(NULL), End(NULL), + Done(false), iOffset(0), + Size(Size) { } FileFd &Fd; diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc index a9d4fb763..cb2c34c0f 100644 --- a/apt-pkg/version.cc +++ b/apt-pkg/version.cc @@ -23,10 +23,10 @@ unsigned long pkgVersioningSystem::GlobalListLen = 0; // pkgVS::pkgVersioningSystem - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Link to the global list of versioning systems supported */ -pkgVersioningSystem::pkgVersioningSystem() +pkgVersioningSystem::pkgVersioningSystem() : Label(NULL) { VSList[GlobalListLen] = this; - GlobalListLen++; + ++GlobalListLen; } /*}}}*/ // pkgVS::GetVS - Find a VS by name /*{{{*/ diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc index 1ccb08804..3ac350aca 100644 --- a/cmdline/acqprogress.cc +++ b/cmdline/acqprogress.cc @@ -31,8 +31,9 @@ using namespace std; // --------------------------------------------------------------------- /* */ AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet) : - ScreenWidth(ScreenWidth), Quiet(Quiet) + ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet) { + BlankLine[0] = 0; } /*}}}*/ // AcqTextStatus::Start - Downloading has started /*{{{*/ diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index d5c1a3208..dc4c110a1 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -53,8 +53,8 @@ pkgCache *DebFile::Cache = 0; // --------------------------------------------------------------------- /* */ DebFile::DebFile(const char *debfile) - : File(debfile, FileFd::ReadOnly), Control(0), DepOp(0), - PreDepOp(0), Config(0), Template(0), Which(None) + : File(debfile, FileFd::ReadOnly), Size(0), Control(NULL), ControlLen(0), + DepOp(0), PreDepOp(0), Config(0), Template(0), Which(None) { } /*}}}*/ diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h index 377c41607..b9ced9418 100644 --- a/ftparchive/cachedb.h +++ b/ftparchive/cachedb.h @@ -126,7 +126,8 @@ class CacheDB Misses += S.Misses; DeLinkBytes += S.DeLinkBytes; }; - Stats() : Bytes(0), MD5Bytes(0), SHA1Bytes(0), SHA256Bytes(0), Packages(0), Misses(0), DeLinkBytes(0) {}; + Stats() : Bytes(0), MD5Bytes(0), SHA1Bytes(0), SHA256Bytes(0), + SHA512Bytes(0),Packages(0), Misses(0), DeLinkBytes(0) {}; } Stats; bool ReadyDB(std::string const &DB); @@ -142,7 +143,7 @@ class CacheDB bool Clean(); - CacheDB(std::string const &DB) : Dbp(0), Fd(NULL), DebFile(0) {ReadyDB(DB);}; + CacheDB(std::string const &DB) : Dbp(0), Fd(NULL), DebFile(0) {TmpKey[0]='\0'; ReadyDB(DB);}; ~CacheDB() {ReadyDB(std::string()); delete DebFile;}; }; diff --git a/methods/ftp.cc b/methods/ftp.cc index ad8a7b828..b1e8d2b0a 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -77,6 +77,7 @@ FTPConn::FTPConn(URI Srv) : Len(0), ServerFd(-1), DataFd(-1), { Debug = _config->FindB("Debug::Acquire::Ftp",false); PasvAddr = 0; + Buffer[0] = '\0'; } /*}}}*/ // FTPConn::~FTPConn - Destructor /*{{{*/ diff --git a/methods/http.h b/methods/http.h index c73d4df5c..5c195de64 100644 --- a/methods/http.h +++ b/methods/http.h @@ -117,9 +117,10 @@ struct ServerState bool HeaderLine(std::string Line); bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;}; - void Reset() {Major = 0; Minor = 0; Result = 0; Size = 0; StartPos = 0; - Encoding = Closes; time(&Date); ServerFd = -1; - Pipeline = true;}; + void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; Size = 0; + StartPos = 0; Encoding = Closes; time(&Date); HaveContent = false; + State = Header; Persistent = false; ServerFd = -1; + Pipeline = true;}; /** \brief Result of the header acquire */ enum RunHeadersResult { diff --git a/methods/rsh.cc b/methods/rsh.cc index d249ae961..fb3782314 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -42,7 +42,9 @@ int RSHMethod::FailFd = -1; // --------------------------------------------------------------------- /* */ RSHConn::RSHConn(URI Srv) : Len(0), WriteFd(-1), ReadFd(-1), - ServerName(Srv), Process(-1) {} + ServerName(Srv), Process(-1) { + Buffer[0] = '\0'; +} /*}}}*/ // RSHConn::RSHConn - Destructor /*{{{*/ // --------------------------------------------------------------------- -- cgit v1.2.3