X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/49f0a5615addcd66e37e0cc4915e42e4c9953054..201d1fa0d25deeda77c2570ee5342eaf18499699:/apt-pkg/pkgcachegen.cc diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index e2934d1fa..68180c702 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -137,7 +137,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, pkgCache::VerIterator Ver = Pkg.VersionList(); map_ptrloc *LastVer = &Pkg->VersionList; - for (; Ver != 0 && Ver.end() == false; LastVer = &Ver->NextVer, Ver++) + for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) { pkgCache::DescIterator Desc = Ver.DescriptionList(); map_ptrloc *LastDesc = &Ver->DescriptionList; @@ -145,7 +145,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, // don't add a new description if we have one for the given // md5 && language - for ( ; Desc != 0 && Desc.end() == false; Desc++) + for ( ; Desc.end() == false; Desc++) if (MD5SumValue(Desc.md5()) == CurMd5 && Desc.LanguageCode() == List.DescriptionLanguage()) duplicate=true; @@ -153,7 +153,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, continue; for (Desc = Ver.DescriptionList(); - Desc != 0 && Desc.end() == false; + Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++) { if (MD5SumValue(Desc.md5()) == CurMd5) @@ -175,7 +175,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, pkgCache::VerIterator Ver = Pkg.VersionList(); map_ptrloc *LastVer = &Pkg->VersionList; int Res = 1; - for (; Ver != 0 && Ver.end() == false; LastVer = &Ver->NextVer, Ver++) + for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) { Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); if (Res >= 0) @@ -209,7 +209,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, // Skip to the end of the same version set. if (Res == 0) { - for (; Ver != 0 && Ver.end() == false; LastVer = &Ver->NextVer, Ver++) + for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) { Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); if (Res != 0) @@ -248,7 +248,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, map_ptrloc *LastDesc = &Ver->DescriptionList; // Skip to the end of description set - for (; Desc != 0 && Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++); + for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++); // Add new description *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc); @@ -306,7 +306,7 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) unsigned long Hash = List.VersionHash(); pkgCache::VerIterator Ver = Pkg.VersionList(); - for (; Ver != 0 && Ver.end() == false; Ver++) + for (; Ver.end() == false; Ver++) { if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr()) { @@ -372,7 +372,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver, // Link it to the end of the list map_ptrloc *Last = &Ver->FileList; - for (pkgCache::VerFileIterator V = Ver.FileList(); V != 0 && V.end() == false; V++) + for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++) Last = &V->NextFile; VF->NextFile = *Last; *Last = VF.Index(); @@ -428,7 +428,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, // Link it to the end of the list map_ptrloc *Last = &Desc->FileList; - for (pkgCache::DescFileIterator D = Desc.FileList(); D != 0 && D.end() == false; D++) + for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++) Last = &D->NextFile; DF->NextFile = *Last; @@ -518,7 +518,7 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver, if (OldDepVer != Ver) { OldDepLast = &Ver->DependsList; - for (pkgCache::DepIterator D = Ver.DependsList(); D != 0 && D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) OldDepLast = &D->NextDepends; OldDepVer = Ver; } @@ -670,7 +670,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start, // Map it FileFd CacheF(CacheFile,FileFd::ReadOnly); - SPtr Map = new MMap(CacheF,MMap::Public | MMap::ReadOnly); + SPtr Map = new MMap(CacheF,0); pkgCache Cache(Map); if (_error->PendingError() == true || Map->Size() == 0) { @@ -854,7 +854,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, else { // Just build it in memory.. - Map = new DynamicMMap(MMap::Public,MapSize); + Map = new DynamicMMap(0,MapSize); } // Lets try the source cache. @@ -866,8 +866,9 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, // Preload the map with the source cache FileFd SCacheF(SrcCacheFile,FileFd::ReadOnly); unsigned long alloc = Map->RawAllocate(SCacheF.Size()); - if (alloc == 0 || SCacheF.Read((unsigned char *)Map->Data() + alloc, - SCacheF.Size()) == false) + if ((alloc == 0 && _error->PendingError()) + || SCacheF.Read((unsigned char *)Map->Data() + alloc, + SCacheF.Size()) == false) return false; TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end()); @@ -928,7 +929,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, if (CacheF != 0) { delete Map.UnGuard(); - *OutMap = new MMap(*CacheF,MMap::Public | MMap::ReadOnly); + *OutMap = new MMap(*CacheF,0); } else { @@ -950,8 +951,7 @@ bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) if (_system->AddStatusFiles(Files) == false) return false; - SPtr Map; - Map = new DynamicMMap(MMap::Public,MapSize); + SPtr Map = new DynamicMMap(0,MapSize); unsigned long CurrentSize = 0; unsigned long TotalSize = 0;