]> git.saurik.com Git - apt.git/commitdiff
Fix an obscure warning from GCC
authorJulian Andres Klode <jak@debian.org>
Tue, 11 Aug 2015 09:05:57 +0000 (11:05 +0200)
committerJulian Andres Klode <jak@debian.org>
Tue, 11 Aug 2015 11:59:15 +0000 (13:59 +0200)
It complained about the previous code:

apt-pkg/sourcelist.cc: In destructor ‘pkgSourceList::~pkgSourceList()’:
apt-pkg/sourcelist.cc:278:4: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations]
    for (pkgIndexFile * const File : VolatileFiles)
    ^
There really cannot be an overflow, though. Rewriting it like this
seems to fix it.

apt-pkg/sourcelist.cc

index 46e51f5928839e095f83f375efdc68b5da9bd106..3e714667c63d07814594db9ff1dc463f3412ef44 100644 (file)
@@ -275,8 +275,8 @@ pkgSourceList::~pkgSourceList()
    for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
       delete *I;
    SrcList.clear();
-   for (pkgIndexFile * const File : VolatileFiles)
-      delete File;
+   for (auto  F = VolatileFiles.begin(); F != VolatileFiles.end(); ++F)
+      delete (*F);
    VolatileFiles.clear();
 }
                                                                        /*}}}*/