Parcourir la source

fix a few more cppcheck performance and scope warnings

David Kalnischkies il y a 15 ans
Parent
commit
91c03d370d

+ 4 - 3
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) {

+ 1 - 2
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)
       {

+ 5 - 5
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)

+ 6 - 6
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)
       {

+ 1 - 1
cmdline/apt-sortpkgs.cc

@@ -106,7 +106,7 @@ bool DoIt(string InFile)
    
    // Emit
    unsigned char *Buffer = new unsigned char[Largest+1];
-   for (vector<PkgName>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<PkgName>::iterator I = List.begin(); I != List.end(); ++I)
    {
       // Read in the Record.
       if (Fd.Seek(I->Offset) == false || Fd.Read(Buffer,I->Length) == false)