Kaynağa Gözat

act on various suggestions from cppcheck

Reported-By: cppcheck
Git-Dch: Ignore
David Kalnischkies 10 yıl önce
ebeveyn
işleme
2651f1c071

+ 4 - 1
apt-pkg/acquire-method.cc

@@ -480,7 +480,10 @@ void pkgAcqMethod::Dequeue() {						/*{{{*/
 									/*}}}*/
 pkgAcqMethod::~pkgAcqMethod() {}
 
-pkgAcqMethod::FetchItem::FetchItem() : d(NULL) {}
+pkgAcqMethod::FetchItem::FetchItem() :
+   Next(nullptr), DestFileFd(-1), LastModified(0), IndexFile(false),
+   FailIgnore(false), MaximumSize(0), d(nullptr)
+{}
 pkgAcqMethod::FetchItem::~FetchItem() {}
 
 pkgAcqMethod::FetchResult::~FetchResult() {}

+ 4 - 17
apt-pkg/acquire-worker.cc

@@ -42,29 +42,16 @@
 using namespace std;
 
 // Worker::Worker - Constructor for Queue startup			/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf,
-			   pkgAcquireStatus *log) : d(NULL), Log(log)
+pkgAcquire::Worker::Worker(Queue *Q, MethodConfig *Cnf, pkgAcquireStatus *log) :
+   d(NULL), OwnerQ(Q), Log(log), Config(Cnf), Access(Cnf->Access),
+   CurrentItem(nullptr), CurrentSize(0), TotalSize(0)
 {
-   OwnerQ = Q;
-   Config = Cnf;
-   Access = Cnf->Access;
-   CurrentItem = 0;
-   TotalSize = 0;
-   CurrentSize = 0;
-
    Construct();
 }
 									/*}}}*/
 // Worker::Worker - Constructor for method config startup		/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgAcquire::Worker::Worker(MethodConfig *Cnf) : d(NULL), OwnerQ(NULL), Config(Cnf),
-						Access(Cnf->Access), CurrentItem(NULL),
-						CurrentSize(0), TotalSize(0)
+pkgAcquire::Worker::Worker(MethodConfig *Cnf) : Worker(nullptr, Cnf, nullptr)
 {
-   Construct();
 }
 									/*}}}*/
 // Worker::Construct - Constructor helper				/*{{{*/

+ 2 - 2
apt-pkg/indexcopy.cc

@@ -771,14 +771,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
 }
 									/*}}}*/
 
-IndexCopy::IndexCopy() : d(NULL) {}
+IndexCopy::IndexCopy() : d(nullptr), Section(nullptr) {}
 APT_CONST IndexCopy::~IndexCopy() {}
 
 PackageCopy::PackageCopy() : IndexCopy(), d(NULL) {}
 APT_CONST PackageCopy::~PackageCopy() {}
 SourceCopy::SourceCopy() : IndexCopy(), d(NULL) {}
 APT_CONST SourceCopy::~SourceCopy() {}
-TranslationsCopy::TranslationsCopy() : d(NULL) {}
+TranslationsCopy::TranslationsCopy() : d(nullptr), Section(nullptr) {}
 APT_CONST TranslationsCopy::~TranslationsCopy() {}
 SigVerify::SigVerify() : d(NULL) {}
 APT_CONST SigVerify::~SigVerify() {}

+ 4 - 0
methods/rred.cc

@@ -491,7 +491,11 @@ class Patch {
       for (ch = filechanges.rbegin(); ch != filechanges.rend(); ++ch) {
 	 std::list<struct Change>::reverse_iterator mg_i, mg_e = ch;
 	 while (ch->del_cnt == 0 && ch->offset == 0)
+	 {
 	    ++ch;
+	    if (unlikely(ch == filechanges.rend()))
+	       return;
+	 }
 	 line -= ch->del_cnt;
 	 std::string buf;
 	 if (ch->add_cnt > 0) {

+ 2 - 1
methods/server.cc

@@ -246,7 +246,8 @@ bool ServerState::HeaderLine(string Line)
 }
 									/*}}}*/
 // ServerState::ServerState - Constructor				/*{{{*/
-ServerState::ServerState(URI Srv, ServerMethod *Owner) : ServerName(Srv), TimeOut(120), Owner(Owner)
+ServerState::ServerState(URI Srv, ServerMethod *Owner) :
+   DownloadSize(0), ServerName(Srv), TimeOut(120), Owner(Owner)
 {
    Reset();
 }