mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-01 07:18:22 -04:00
ams: revamp assertion system
This commit is contained in:
parent
9572fb2ce3
commit
40400aee1f
168 changed files with 1014 additions and 696 deletions
|
@ -84,7 +84,7 @@ namespace ams::kvdb {
|
|||
|
||||
Result ArchiveReader::ReadEntryCount(size_t *out) {
|
||||
/* This should only be called at the start of reading stream. */
|
||||
AMS_ASSERT(this->offset == 0);
|
||||
AMS_ABORT_UNLESS(this->offset == 0);
|
||||
|
||||
/* Read and validate header. */
|
||||
ArchiveHeader header;
|
||||
|
@ -97,7 +97,7 @@ namespace ams::kvdb {
|
|||
|
||||
Result ArchiveReader::GetEntrySize(size_t *out_key_size, size_t *out_value_size) {
|
||||
/* This should only be called after ReadEntryCount. */
|
||||
AMS_ASSERT(this->offset != 0);
|
||||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
/* Peek the next entry header. */
|
||||
ArchiveEntryHeader header;
|
||||
|
@ -111,7 +111,7 @@ namespace ams::kvdb {
|
|||
|
||||
Result ArchiveReader::ReadEntry(void *out_key, size_t key_size, void *out_value, size_t value_size) {
|
||||
/* This should only be called after ReadEntryCount. */
|
||||
AMS_ASSERT(this->offset != 0);
|
||||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
/* Read the next entry header. */
|
||||
ArchiveEntryHeader header;
|
||||
|
@ -119,11 +119,11 @@ namespace ams::kvdb {
|
|||
R_TRY(header.Validate());
|
||||
|
||||
/* Key size and Value size must be correct. */
|
||||
AMS_ASSERT(key_size == header.key_size);
|
||||
AMS_ASSERT(value_size == header.value_size);
|
||||
AMS_ABORT_UNLESS(key_size == header.key_size);
|
||||
AMS_ABORT_UNLESS(value_size == header.value_size);
|
||||
|
||||
R_ASSERT(this->Read(out_key, key_size));
|
||||
R_ASSERT(this->Read(out_value, value_size));
|
||||
R_ABORT_UNLESS(this->Read(out_key, key_size));
|
||||
R_ABORT_UNLESS(this->Read(out_value, value_size));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
@ -140,20 +140,20 @@ namespace ams::kvdb {
|
|||
|
||||
void ArchiveWriter::WriteHeader(size_t entry_count) {
|
||||
/* This should only be called at start of write. */
|
||||
AMS_ASSERT(this->offset == 0);
|
||||
AMS_ABORT_UNLESS(this->offset == 0);
|
||||
|
||||
ArchiveHeader header = ArchiveHeader::Make(entry_count);
|
||||
R_ASSERT(this->Write(&header, sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
|
||||
}
|
||||
|
||||
void ArchiveWriter::WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size) {
|
||||
/* This should only be called after writing header. */
|
||||
AMS_ASSERT(this->offset != 0);
|
||||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size);
|
||||
R_ASSERT(this->Write(&header, sizeof(header)));
|
||||
R_ASSERT(this->Write(key, key_size));
|
||||
R_ASSERT(this->Write(value, value_size));
|
||||
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(key, key_size));
|
||||
R_ABORT_UNLESS(this->Write(value, value_size));
|
||||
}
|
||||
|
||||
/* Size helper functionality. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue