Просмотр исходного кода

Fix an obscure warning from GCC

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.
Julian Andres Klode лет назад: 11
Родитель
Сommit
c9d715346c
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      apt-pkg/sourcelist.cc

+ 2 - 2
apt-pkg/sourcelist.cc

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