From: David Kalnischkies Date: Thu, 11 Aug 2011 21:01:15 +0000 (+0200) Subject: fix a few more cppcheck performance and scope warnings X-Git-Tag: 0.8.15.6~2^2~2 X-Git-Url: https://git.hcoop.net/ntk/apt.git/commitdiff_plain/91c03d370d36b7a802b841394fb6afdccbd34893 fix a few more cppcheck performance and scope warnings --- diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 34f472ee..9ff5796c 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -47,10 +47,7 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) int specific_login = (login[0] != 0); char *home = NULL; bool netrc_alloc = false; - int state = NOTHING; - char state_login = 0; /* Found a login keyword */ - char state_password = 0; /* Found a password keyword */ int state_our_login = false; /* With specific_login, found *our* login name */ @@ -81,6 +78,10 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) bool done = false; char netrcbuffer[256]; + int state = NOTHING; + char state_login = 0; /* Found a login keyword */ + char state_password = 0; /* Found a password keyword */ + while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) { tok = strtok_r (netrcbuffer, " \t\n", &tok_buf); while (!done && tok) { diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index b262e21c..747e464b 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -885,7 +885,6 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ this->Section = &Section; string Prefix; unsigned long Hits = 0; - unsigned long Chop = 0; while (Parser.Step(Section) == true) { if(Progress) @@ -903,7 +902,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ fclose(TargetFl); if (Debug == true) - cout << " Processed by using Prefix '" << Prefix << "' and chop " << Chop << endl; + cout << " Processed by using Prefix '" << Prefix << "' and chop " << endl; if (_config->FindB("APT::CDROM::NoAct",false) == false) { diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 6034138c..a58efa98 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -145,13 +145,13 @@ bool pkgOrderList::DoRun() Depth = 0; WipeFlags(Added | AddPending | Loop | InList); - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) Flag(*I,InList); // Rebuild the main list into the temp list. iterator OldEnd = End; End = NList; - for (iterator I = List; I != OldEnd; I++) + for (iterator I = List; I != OldEnd; ++I) if (VisitNode(PkgIterator(Cache,*I)) == false) { End = OldEnd; @@ -197,7 +197,7 @@ bool pkgOrderList::OrderCritical() { clog << "** Critical Unpack ordering done" << endl; - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsNow(P) == true) @@ -222,7 +222,7 @@ bool pkgOrderList::OrderUnpack(string *FileList) WipeFlags(After); // Set the inlist flag - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsMissing(P) == true && IsNow(P) == true) @@ -270,7 +270,7 @@ bool pkgOrderList::OrderUnpack(string *FileList) { clog << "** Unpack ordering done" << endl; - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsNow(P) == true) diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 999a7b0a..060cd324 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -63,7 +63,7 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, if (ordering == false) return _error->Error("Internal ordering error"); - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); FileNames[Pkg->ID] = string(); @@ -262,7 +262,7 @@ bool pkgPackageManager::ConfigureAll() pkgOrderList OList(&Cache); // Populate the order list - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) if (List->IsFlag(pkgCache::PkgIterator(Cache,*I), pkgOrderList::UnPacked) == true) OList.push_back(*I); @@ -274,7 +274,7 @@ bool pkgPackageManager::ConfigureAll() bool const ConfigurePkgs = (conf == "all"); // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) + for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I) { PkgIterator Pkg(Cache,*I); @@ -309,7 +309,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) return false; // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) + for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I) { PkgIterator Pkg(Cache,*I); @@ -652,7 +652,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() clog << "Done ordering" << endl; bool DoneSomething = false; - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); @@ -701,7 +701,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() return Failed; // Sanity check - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { if (List->IsFlag(*I,pkgOrderList::Configured) == false) { diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 171b0ba1..f95a434c 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -106,7 +106,7 @@ bool DoIt(string InFile) // Emit unsigned char *Buffer = new unsigned char[Largest+1]; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Read in the Record. if (Fd.Seek(I->Offset) == false || Fd.Read(Buffer,I->Length) == false)