Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Pass Roles by reference after all.
Browse files Browse the repository at this point in the history
Based on clang-tidy's advice.

Signed-off-by: Patrick Vacek <[email protected]>
  • Loading branch information
pattivacek committed Jan 29, 2019
1 parent 4e955a5 commit e583ca1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/libaktualizr/uptane/imagesrepository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool ImagesRepository::verifySnapshot(const std::string& snapshot_raw) {
return true;
}

bool ImagesRepository::verifyTargets(const std::string& targets_raw, const Uptane::Role role) {
bool ImagesRepository::verifyTargets(const std::string& targets_raw, const Uptane::Role& role) {
try {
const Json::Value targets_json = Utils::parseJSON(targets_raw);
const std::string canonical = Utils::jsonToCanonicalStr(targets_json);
Expand Down
2 changes: 1 addition & 1 deletion src/libaktualizr/uptane/imagesrepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ImagesRepository : public RepositoryCommon {

void resetMeta();

bool verifyTargets(const std::string& targets_raw, Uptane::Role role);
bool verifyTargets(const std::string& targets_raw, const Uptane::Role& role);
bool targetsExpired(const std::string& role_name) { return targets[role_name].isExpired(TimeStamp::Now()); }
int64_t targetsSize() { return snapshot.targets_size(); }
std::set<std::string> delegations(const std::string& role_name) { return targets[role_name].delegated_role_names_; }
Expand Down
4 changes: 2 additions & 2 deletions src/libaktualizr/uptane/metawithkeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Uptane::MetaWithKeys;

MetaWithKeys::MetaWithKeys(const Json::Value &json) : BaseMeta(json) {}
MetaWithKeys::MetaWithKeys(RepositoryType repo, const Role role, const Json::Value &json,
MetaWithKeys::MetaWithKeys(RepositoryType repo, const Role &role, const Json::Value &json,
const std::shared_ptr<MetaWithKeys> &signer)
: BaseMeta(repo, role, json, signer) {}

Expand Down Expand Up @@ -55,7 +55,7 @@ void Uptane::MetaWithKeys::ParseRole(const RepositoryType repo, const Json::Valu
}
}

void Uptane::MetaWithKeys::UnpackSignedObject(const RepositoryType repo, const Role role,
void Uptane::MetaWithKeys::UnpackSignedObject(const RepositoryType repo, const Role &role,
const Json::Value &signed_object) {
const std::string repository = repo;

Expand Down
2 changes: 1 addition & 1 deletion src/libaktualizr/uptane/root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Root::Root(const RepositoryType repo, const Json::Value &json) : MetaWithKeys(js
}
}

void Uptane::Root::UnpackSignedObject(const RepositoryType repo, const Role role, const Json::Value &signed_object) {
void Uptane::Root::UnpackSignedObject(const RepositoryType repo, const Role &role, const Json::Value &signed_object) {
const std::string repository = repo;

if (policy_ == Policy::kAcceptAll) {
Expand Down
4 changes: 2 additions & 2 deletions src/libaktualizr/uptane/tuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void Uptane::BaseMeta::init(const Json::Value &json) {
}
Uptane::BaseMeta::BaseMeta(const Json::Value &json) { init(json); }

Uptane::BaseMeta::BaseMeta(RepositoryType repo, const Role role, const Json::Value &json,
Uptane::BaseMeta::BaseMeta(RepositoryType repo, const Role &role, const Json::Value &json,
const std::shared_ptr<MetaWithKeys> &signer) {
if (!json.isObject() || !json.isMember("signed")) {
throw Uptane::InvalidMetadata("", "", "invalid metadata json");
Expand Down Expand Up @@ -303,7 +303,7 @@ void Uptane::Targets::init(const Json::Value &json) {

Uptane::Targets::Targets(const Json::Value &json) : MetaWithKeys(json) { init(json); }

Uptane::Targets::Targets(RepositoryType repo, const Role role, const Json::Value &json,
Uptane::Targets::Targets(RepositoryType repo, const Role &role, const Json::Value &json,
const std::shared_ptr<MetaWithKeys> &signer)
: MetaWithKeys(repo, role, json, signer), name_(role.ToString()) {
init(json);
Expand Down
11 changes: 6 additions & 5 deletions src/libaktualizr/uptane/tuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class BaseMeta {
public:
BaseMeta() = default;
explicit BaseMeta(const Json::Value &json);
BaseMeta(RepositoryType repo, Role role, const Json::Value &json, const std::shared_ptr<MetaWithKeys> &signer);
BaseMeta(RepositoryType repo, const Role &role, const Json::Value &json, const std::shared_ptr<MetaWithKeys> &signer);
int version() const { return version_; }
TimeStamp expiry() const { return expiry_; }
bool isExpired(const TimeStamp &now) const { return expiry_.IsExpiredAt(now); }
Expand Down Expand Up @@ -339,7 +339,8 @@ class MetaWithKeys : public BaseMeta {
* @param json - The contents of the 'signed' portion
*/
MetaWithKeys(const Json::Value &json);
MetaWithKeys(RepositoryType repo, Role role, const Json::Value &json, const std::shared_ptr<MetaWithKeys> &signer);
MetaWithKeys(RepositoryType repo, const Role &role, const Json::Value &json,
const std::shared_ptr<MetaWithKeys> &signer);

virtual ~MetaWithKeys() = default;

Expand All @@ -361,7 +362,7 @@ class MetaWithKeys : public BaseMeta {
* @param signed_object
* @return
*/
virtual void UnpackSignedObject(RepositoryType repo, Role role, const Json::Value &signed_object);
virtual void UnpackSignedObject(RepositoryType repo, const Role &role, const Json::Value &signed_object);

bool operator==(const MetaWithKeys &rhs) const {
return version_ == rhs.version_ && expiry_ == rhs.expiry_ && keys_ == rhs.keys_ &&
Expand Down Expand Up @@ -407,7 +408,7 @@ class Root : public MetaWithKeys {
* @param signed_object
* @return
*/
void UnpackSignedObject(RepositoryType repo, Role role, const Json::Value &signed_object) override;
void UnpackSignedObject(RepositoryType repo, const Role &role, const Json::Value &signed_object) override;

bool operator==(const Root &rhs) const {
return version_ == rhs.version_ && expiry_ == rhs.expiry_ && keys_ == rhs.keys_ &&
Expand All @@ -423,7 +424,7 @@ class Root : public MetaWithKeys {
class Targets : public MetaWithKeys {
public:
explicit Targets(const Json::Value &json);
Targets(RepositoryType repo, Role role, const Json::Value &json, const std::shared_ptr<MetaWithKeys> &signer);
Targets(RepositoryType repo, const Role &role, const Json::Value &json, const std::shared_ptr<MetaWithKeys> &signer);
Targets() = default;
~Targets() override = default;

Expand Down

0 comments on commit e583ca1

Please sign in to comment.