diff options
-rw-r--r-- | apt-pkg/acquire-item.cc | 29 | ||||
-rw-r--r-- | apt-pkg/acquire-item.h | 18 |
2 files changed, 20 insertions, 27 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 9b809db71..a5a3b564b 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -190,14 +190,14 @@ static bool MessageInsecureRepository(bool const isError, std::string const &msg _error->Notice("%s", _("See apt-secure(8) manpage for repository creation and user configuration details.")); return false; } -static bool MessageInsecureRepository(bool const isError, char const * const msg, std::string const &repo) +static bool APT_NONNULL(2) MessageInsecureRepository(bool const isError, char const * const msg, std::string const &repo) { std::string m; strprintf(m, msg, repo.c_str()); return MessageInsecureRepository(isError, m); } /*}}}*/ -static bool AllowInsecureRepositories(char const * const msg, std::string const &repo,/*{{{*/ +static bool APT_NONNULL(1, 3, 4, 5) AllowInsecureRepositories(char const * const msg, std::string const &repo,/*{{{*/ metaIndex const * const MetaIndexParser, pkgAcqMetaClearSig * const TransactionManager, pkgAcquire::Item * const I) { if(MetaIndexParser->GetTrusted() == metaIndex::TRI_YES) @@ -239,8 +239,7 @@ APT_CONST bool pkgAcqTransactionItem::HashesRequired() const we can at least trust them for integrity of the download itself. Only repositories without a Release file can (obviously) not have hashes – and they are very uncommon and strongly discouraged */ - return TransactionManager->MetaIndexParser != NULL && - TransactionManager->MetaIndexParser->GetLoadedSuccessfully() == metaIndex::TRI_YES; + return TransactionManager->MetaIndexParser->GetLoadedSuccessfully() == metaIndex::TRI_YES; } HashStringList pkgAcqTransactionItem::GetExpectedHashes() const { @@ -331,15 +330,14 @@ bool pkgAcqTransactionItem::QueueURI(pkgAcquire::ItemDesc &Item) return false; } std::string const FinalFile = GetFinalFilename(); - if (TransactionManager != NULL && TransactionManager->IMSHit == true && - FileExists(FinalFile) == true) + if (TransactionManager->IMSHit == true && FileExists(FinalFile) == true) { PartialFile = DestFile = FinalFile; Status = StatDone; return false; } // If we got the InRelease file via a mirror, pick all indexes directly from this mirror, too - if (TransactionManager != nullptr && TransactionManager->BaseURI.empty() == false && + if (TransactionManager->BaseURI.empty() == false && URI::SiteOnly(Item.URI) != URI::SiteOnly(TransactionManager->BaseURI)) { // this ensures we rewrite only once and only the first step @@ -1137,8 +1135,7 @@ bool pkgAcqMetaBase::CheckDownloadDone(pkgAcqTransactionItem * const I, const st { // for simplicity, the transaction manager is always InRelease // even if it doesn't exist. - if (TransactionManager != NULL) - TransactionManager->IMSHit = true; + TransactionManager->IMSHit = true; I->PartialFile = I->DestFile = I->GetFinalFilename(); } @@ -1201,10 +1198,7 @@ void pkgAcqMetaBase::QueueIndexes(bool const verify) /*{{{*/ // at this point the real Items are loaded in the fetcher ExpectedAdditionalItems = 0; - bool metaBaseSupportsByHash = false; - if (TransactionManager != NULL && TransactionManager->MetaIndexParser != NULL) - metaBaseSupportsByHash = TransactionManager->MetaIndexParser->GetSupportsAcquireByHash(); - + bool const metaBaseSupportsByHash = TransactionManager->MetaIndexParser->GetSupportsAcquireByHash(); for (std::vector <IndexTarget>::iterator Target = IndexTargets.begin(); Target != IndexTargets.end(); ++Target) @@ -1487,7 +1481,7 @@ void pkgAcqMetaClearSig::Finished() /*{{{*/ { if(_config->FindB("Debug::Acquire::Transaction", false) == true) std::clog << "Finished: " << DestFile <<std::endl; - if(TransactionManager != NULL && TransactionManager->State == TransactionStarted && + if(TransactionManager->State == TransactionStarted && TransactionManager->TransactionHasError() == false) TransactionManager->CommitTransaction(); } @@ -1820,8 +1814,7 @@ pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner, void pkgAcqBaseIndex::Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf)/*{{{*/ { pkgAcquire::Item::Failed(Message, Cnf); - if (TransactionManager == nullptr || TransactionManager->MetaIndexParser == nullptr || - Status != StatAuthError) + if (Status != StatAuthError) return; ErrorText.append("Release file created at: "); @@ -2167,7 +2160,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/ // calculate the size of all patches we have to get unsigned short const sizeLimitPercent = _config->FindI("Acquire::PDiffs::SizeLimit", 100); - if (sizeLimitPercent > 0 && TransactionManager->MetaIndexParser != nullptr) + if (sizeLimitPercent > 0) { unsigned long long downloadSize = std::accumulate(available_patches.begin(), available_patches.end(), 0llu, [](unsigned long long const T, DiffInfo const &I) { @@ -2733,7 +2726,7 @@ void pkgAcqIndex::Init(string const &URI, string const &URIDesc, else if (CurrentCompressionExtension == "by-hash") { NextCompressionExtension(CurrentCompressionExtension, CompressionExtensions, true); - if(unlikely(TransactionManager->MetaIndexParser == NULL || CurrentCompressionExtension.empty())) + if(unlikely(CurrentCompressionExtension.empty())) return; if (CurrentCompressionExtension != "uncompressed") { diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 41420a7c1..81b6d3944 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -393,7 +393,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/ virtual bool HashesRequired() const APT_OVERRIDE; - pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target); + pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target) APT_NONNULL(2, 3); virtual ~pkgAcqTransactionItem(); friend class pkgAcqMetaBase; @@ -495,7 +495,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/ pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, std::vector<IndexTarget> const &IndexTargets, - IndexTarget const &DataTarget); + IndexTarget const &DataTarget) APT_NONNULL(2, 3); virtual ~pkgAcqMetaBase(); }; /*}}}*/ @@ -529,7 +529,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget, - std::vector<IndexTarget> const &IndexTargets); + std::vector<IndexTarget> const &IndexTargets) APT_NONNULL(2, 3); virtual ~pkgAcqMetaIndex(); friend class pkgAcqMetaSig; @@ -568,7 +568,7 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem /** \brief Create a new pkgAcqMetaSig. */ pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, - IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex); + IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex) APT_NONNULL(2, 3, 5); virtual ~pkgAcqMetaSig(); }; /*}}}*/ @@ -613,7 +613,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE; pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, - IndexTarget const &Target); + IndexTarget const &Target) APT_NONNULL(2, 3); virtual ~pkgAcqBaseIndex(); }; /*}}}*/ @@ -678,7 +678,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex * \param ShortDesc A short description of the list file to download. */ pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, - IndexTarget const &Target); + IndexTarget const &Target) APT_NONNULL(2, 3); virtual ~pkgAcqDiffIndex(); private: APT_HIDDEN void QueueOnIMSHit() const; @@ -778,7 +778,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex */ pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target, DiffInfo const &patch, - std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches); + std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches) APT_NONNULL(2, 3, 6); virtual ~pkgAcqIndexMergeDiffs(); }; /*}}}*/ @@ -889,7 +889,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex */ pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target, - std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>()); + std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>()) APT_NONNULL(2, 3); virtual ~pkgAcqIndexDiffs(); }; /*}}}*/ @@ -956,7 +956,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex virtual std::string GetMetaKey() const APT_OVERRIDE; pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, - IndexTarget const &Target); + IndexTarget const &Target) APT_NONNULL(2, 3); virtual ~pkgAcqIndex(); private: |