summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2026-04-08 10:26:28 +0000
committerJulian Andres Klode <jak@debian.org>2026-04-08 10:26:28 +0000
commit5b649fb72ecdced056fb3daab02e88933cc7a32a (patch)
tree42e82e842dafa0dd9f4fcaab2d23968200f10062
parenta6873075dcac5115706e001bc9640c8da0805e35 (diff)
parentdf63b982447f1a8f699e6547352cd04d00242c9b (diff)
Merge branch 'range-loop-acquire' into 'main'
apt-pkg/acquire: use range based for loop C++17 See merge request apt-team/apt!564
-rw-r--r--apt-pkg/acquire.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 17caa42b6..7a60c4476 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -795,8 +795,8 @@ stop:
I->Shutdown(false);
// Shut down the items
- for (ItemIterator I = Items.begin(); I != Items.end(); ++I)
- (*I)->Finished();
+ for (auto &Item : Items)
+ Item->Finished();
bool const newError = _error->PendingError();
_error->MergeWithStack();
@@ -1191,10 +1191,10 @@ pkgAcquire::Queue::QItem *pkgAcquire::Queue::FindItem(string URI,pkgAcquire::Wor
bool pkgAcquire::Queue::ItemDone(QItem *Itm)
{
PipeDepth--;
- for (QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
+ for (auto Owner : Itm->Owners)
{
- if ((*O)->Status == pkgAcquire::Item::StatFetching)
- (*O)->Status = pkgAcquire::Item::StatDone;
+ if (Owner->Status == pkgAcquire::Item::StatFetching)
+ Owner->Status = pkgAcquire::Item::StatDone;
}
if (Itm->Owner->QueueCounter <= 1)
@@ -1273,9 +1273,9 @@ HashStringList pkgAcquire::Queue::QItem::GetExpectedHashes() const /*{{{*/
failure and still needs this handling: Two owners who expect the same
file, but one owner only knows the SHA1 while the other only knows SHA256. */
HashStringList superhsl;
- for (pkgAcquire::Queue::QItem::owner_iterator O = Owners.begin(); O != Owners.end(); ++O)
+ for (auto Owner : Owners)
{
- HashStringList const hsl = (*O)->GetExpectedHashes();
+ HashStringList const hsl = Owner->GetExpectedHashes();
// we merge both lists - if we find disagreement send no hashes
HashStringList::const_iterator hs = hsl.begin();
for (; hs != hsl.end(); ++hs)
@@ -1329,24 +1329,24 @@ void pkgAcquire::Queue::QItem::SyncDestinationFiles() const /*{{{*/
everything (like progress reporting) finds it easily */
std::string superfile = Owner->DestFile;
off_t supersize = 0;
- for (pkgAcquire::Queue::QItem::owner_iterator O = Owners.begin(); O != Owners.end(); ++O)
+ for (auto Owner : Owners)
{
- if ((*O)->DestFile == superfile)
+ if (Owner->DestFile == superfile)
continue;
struct stat file;
- if (lstat((*O)->DestFile.c_str(),&file) == 0)
+ if (lstat(Owner->DestFile.c_str(),&file) == 0)
{
if ((file.st_mode & S_IFREG) == 0)
- RemoveFile("SyncDestinationFiles", (*O)->DestFile);
+ RemoveFile("SyncDestinationFiles", Owner->DestFile);
else if (supersize < file.st_size)
{
supersize = file.st_size;
RemoveFile("SyncDestinationFiles", superfile);
- rename((*O)->DestFile.c_str(), superfile.c_str());
+ rename(Owner->DestFile.c_str(), superfile.c_str());
}
else
- RemoveFile("SyncDestinationFiles", (*O)->DestFile);
- if (symlink(superfile.c_str(), (*O)->DestFile.c_str()) != 0)
+ RemoveFile("SyncDestinationFiles", Owner->DestFile);
+ if (symlink(superfile.c_str(), Owner->DestFile.c_str()) != 0)
{
; // not a problem per-se and no real alternative
}