ams: revamp assertion system
This commit is contained in:
@@ -21,8 +21,8 @@ namespace ams::util {
|
||||
/* Compression utilities. */
|
||||
int CompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size) {
|
||||
/* Size checks. */
|
||||
AMS_ASSERT(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ASSERT(src_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(src_size <= std::numeric_limits<int>::max());
|
||||
|
||||
/* This is just a thin wrapper around LZ4. */
|
||||
return LZ4_compress_default(reinterpret_cast<const char *>(src), reinterpret_cast<char *>(dst), static_cast<int>(src_size), static_cast<int>(dst_size));
|
||||
@@ -31,8 +31,8 @@ namespace ams::util {
|
||||
/* Decompression utilities. */
|
||||
int DecompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size) {
|
||||
/* Size checks. */
|
||||
AMS_ASSERT(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ASSERT(src_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(dst_size <= std::numeric_limits<int>::max());
|
||||
AMS_ABORT_UNLESS(src_size <= std::numeric_limits<int>::max());
|
||||
|
||||
/* This is just a thin wrapper around LZ4. */
|
||||
return LZ4_decompress_safe(reinterpret_cast<const char *>(src), reinterpret_cast<char *>(dst), static_cast<int>(src_size), static_cast<int>(dst_size));
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ams::util::ini {
|
||||
|
||||
explicit FsFileContext(FsFile *f) : f(f), offset(0) {
|
||||
s64 size;
|
||||
R_ASSERT(fsFileGetSize(this->f, &size));
|
||||
R_ABORT_UNLESS(fsFileGetSize(this->f, &size));
|
||||
this->num_left = size_t(size);
|
||||
}
|
||||
};
|
||||
@@ -46,8 +46,8 @@ namespace ams::util::ini {
|
||||
/* Read as many bytes as we can. */
|
||||
size_t try_read = std::min(size_t(num - 1), ctx->num_left);
|
||||
size_t actually_read;
|
||||
R_ASSERT(fsFileRead(ctx->f, ctx->offset, str, try_read, FsReadOption_None, &actually_read));
|
||||
AMS_ASSERT(actually_read == try_read);
|
||||
R_ABORT_UNLESS(fsFileRead(ctx->f, ctx->offset, str, try_read, FsReadOption_None, &actually_read));
|
||||
AMS_ABORT_UNLESS(actually_read == try_read);
|
||||
|
||||
/* Only "read" up to the first \n. */
|
||||
size_t offset = actually_read;
|
||||
|
||||
Reference in New Issue
Block a user