ams: replace most remaining operator & with std::addressof
This commit is contained in:
@@ -245,8 +245,8 @@ namespace ams::kvdb {
|
||||
static Result ValidateExistingCache(const char *dir) {
|
||||
/* Check for existence. */
|
||||
bool has_lru = false, has_kvs = false;
|
||||
R_TRY(FileExists(&has_lru, GetLeastRecentlyUsedListPath(dir)));
|
||||
R_TRY(DirectoryExists(&has_kvs, GetFileKeyValueStorePath(dir)));
|
||||
R_TRY(FileExists(std::addressof(has_lru), GetLeastRecentlyUsedListPath(dir)));
|
||||
R_TRY(DirectoryExists(std::addressof(has_kvs), GetFileKeyValueStorePath(dir)));
|
||||
|
||||
/* If neither exists, CreateNewCache was never called. */
|
||||
R_UNLESS(has_lru || has_kvs, kvdb::ResultNotCreated());
|
||||
|
||||
@@ -84,38 +84,38 @@ namespace ams::kvdb {
|
||||
template<typename Key>
|
||||
Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) {
|
||||
static_assert(util::is_pod<Key>::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!");
|
||||
return this->Get(out_size, out_value, max_out_size, &key, sizeof(Key));
|
||||
return this->Get(out_size, out_value, max_out_size, std::addressof(key), sizeof(Key));
|
||||
}
|
||||
|
||||
template<typename Key, typename Value>
|
||||
Result Get(Value *out_value, const Key &key) {
|
||||
static_assert(util::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!");
|
||||
size_t size = 0;
|
||||
R_TRY(this->Get(&size, out_value, sizeof(Value), key));
|
||||
R_TRY(this->Get(std::addressof(size), out_value, sizeof(Value), key));
|
||||
AMS_ABORT_UNLESS(size >= sizeof(Value));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
Result GetSize(size_t *out_size, const Key &key) {
|
||||
return this->GetSize(out_size, &key, sizeof(Key));
|
||||
return this->GetSize(out_size, std::addressof(key), sizeof(Key));
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
Result Set(const Key &key, const void *value, size_t value_size) {
|
||||
static_assert(util::is_pod<Key>::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!");
|
||||
return this->Set(&key, sizeof(Key), value, value_size);
|
||||
return this->Set(std::addressof(key), sizeof(Key), value, value_size);
|
||||
}
|
||||
|
||||
template<typename Key, typename Value>
|
||||
Result Set(const Key &key, const Value &value) {
|
||||
static_assert(util::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!");
|
||||
return this->Set(key, &value, sizeof(Value));
|
||||
return this->Set(key, std::addressof(value), sizeof(Value));
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
Result Remove(const Key &key) {
|
||||
return this->Remove(&key, sizeof(Key));
|
||||
return this->Remove(std::addressof(key), sizeof(Key));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace ams::kvdb {
|
||||
/* Try to read the archive -- note, path not found is a success condition. */
|
||||
/* This is because no archive file = no entries, so we're in the right state. */
|
||||
AutoBuffer buffer;
|
||||
R_TRY_CATCH(this->ReadArchiveFile(&buffer)) {
|
||||
R_TRY_CATCH(this->ReadArchiveFile(std::addressof(buffer))) {
|
||||
R_CONVERT(fs::ResultPathNotFound, ResultSuccess());
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
@@ -315,12 +315,12 @@ namespace ams::kvdb {
|
||||
ArchiveReader reader(buffer);
|
||||
|
||||
size_t entry_count = 0;
|
||||
R_TRY(reader.ReadEntryCount(&entry_count));
|
||||
R_TRY(reader.ReadEntryCount(std::addressof(entry_count)));
|
||||
|
||||
for (size_t i = 0; i < entry_count; i++) {
|
||||
/* Get size of key/value. */
|
||||
size_t key_size = 0, value_size = 0;
|
||||
R_TRY(reader.GetEntrySize(&key_size, &value_size));
|
||||
R_TRY(reader.GetEntrySize(std::addressof(key_size), std::addressof(value_size)));
|
||||
|
||||
/* Allocate memory for value. */
|
||||
void *new_value = this->memory_resource->Allocate(value_size);
|
||||
@@ -329,7 +329,7 @@ namespace ams::kvdb {
|
||||
|
||||
/* Read key and value. */
|
||||
Key key;
|
||||
R_TRY(reader.ReadEntry(&key, sizeof(key), new_value, value_size));
|
||||
R_TRY(reader.ReadEntry(std::addressof(key), sizeof(key), new_value, value_size));
|
||||
R_TRY(this->index.AddUnsafe(key, new_value, value_size));
|
||||
|
||||
/* We succeeded, so cancel the value guard to prevent deallocation. */
|
||||
@@ -351,7 +351,7 @@ namespace ams::kvdb {
|
||||
writer.WriteHeader(this->GetCount());
|
||||
for (const auto &it : this->index) {
|
||||
const auto &key = it.GetKey();
|
||||
writer.WriteEntry(&key, sizeof(Key), it.GetValuePointer(), it.GetValueSize());
|
||||
writer.WriteEntry(std::addressof(key), sizeof(Key), it.GetValuePointer(), it.GetValueSize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ namespace ams::kvdb {
|
||||
Result Set(const Key &key, const Value &value) {
|
||||
/* Only allow setting pod. */
|
||||
static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod");
|
||||
return this->Set(key, &value, sizeof(Value));
|
||||
return this->Set(key, std::addressof(value), sizeof(Value));
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
|
||||
Reference in New Issue
Block a user