diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 7b1c3c9256..8ef949a65e 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -327,13 +327,7 @@ int OSCopyFile(const char* source, const char* destination, bool overwrite) //sendfile will work with non-socket output (i.e. regular file) on Linux 2.6.33+ off_t bytesCopied = 0; struct stat fileinfo = { 0 }; - - s32 ret = fstat(input, &fileinfo); - if (ret < 0) - { - return -1; - } - + fstat(input, &fileinfo); int result = sendfile(output, input, &bytesCopied, fileinfo.st_size) == -1 ? -1 : 0; #endif diff --git a/Utilities/VirtualMemory.cpp b/Utilities/VirtualMemory.cpp index b018bb2e1f..5a2d00e901 100644 --- a/Utilities/VirtualMemory.cpp +++ b/Utilities/VirtualMemory.cpp @@ -17,55 +17,29 @@ namespace memory_helper { #ifdef _WIN32 void* ret = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS); - if (ret == NULL) - { - LOG_ERROR(HLE, "reserve_memory VirtualAlloc failed."); - return (void*)VM_FAILURE; - } + CHECK_ASSERTION(ret != NULL); #else void* ret = mmap(nullptr, size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (ret == (void*)VM_FAILURE) - { - LOG_ERROR(HLE, "reserve_memory mmap failed."); - } + CHECK_ASSERTION(ret != 0); #endif return ret; } - s32 commit_page_memory(void* pointer, size_t page_size) + void commit_page_memory(void* pointer, size_t page_size) { #ifdef _WIN32 - if (VirtualAlloc((u8*)pointer, page_size, MEM_COMMIT, PAGE_READWRITE) == NULL) - { - LOG_ERROR(HLE, "commit_page_memory VirtualAlloc failed."); - return VM_FAILURE; - } + CHECK_ASSERTION(VirtualAlloc((u8*)pointer, page_size, MEM_COMMIT, PAGE_READWRITE) != NULL); #else - s32 ret = mprotect((u8*)pointer, page_size, PROT_READ | PROT_WRITE); - if (ret < VM_SUCCESS) - { - LOG_ERROR(HLE, "commit_page_memory mprotect failed. (%d)", ret); - return VM_FAILURE; - } + CHECK_ASSERTION(mprotect((u8*)pointer, page_size, PROT_READ | PROT_WRITE) != -1); #endif - return VM_SUCCESS; } - s32 free_reserved_memory(void* pointer, size_t size) + void free_reserved_memory(void* pointer, size_t size) { #ifdef _WIN32 - if (VirtualFree(pointer, 0, MEM_RELEASE) == 0) - { - LOG_ERROR(HLE, "free_reserved_memory VirtualFree failed."); - return VM_FAILURE; - } + CHECK_ASSERTION(VirtualFree(pointer, 0, MEM_RELEASE) != 0); #else - if (munmap(pointer, size) != VM_SUCCESS) - { - LOG_ERROR(HLE, "free_reserved_memory munmap failed."); - return VM_FAILURE; - } + CHECK_ASSERTION(munmap(pointer, size) == 0); #endif - return VM_SUCCESS; } } diff --git a/Utilities/VirtualMemory.h b/Utilities/VirtualMemory.h index 1810bf0c71..ecce48db2e 100644 --- a/Utilities/VirtualMemory.h +++ b/Utilities/VirtualMemory.h @@ -1,20 +1,10 @@ #pragma once -// Failure codes for the functions -enum -{ - VM_SUCCESS = 0, - VM_FAILURE = -1, -}; - namespace memory_helper { /** * Reserve size bytes of virtual memory and returns it. * The memory should be commited before usage. - * - * Returns the base address of the allocated region of pages, if successful. - * Returns (void*)VM_FAILURE, if unsuccessful. */ void* reserve_memory(size_t size); @@ -22,17 +12,11 @@ namespace memory_helper * Commit page_size bytes of virtual memory starting at pointer. * That is, bake reserved memory with physical memory. * pointer should belong to a range of reserved memory. - * - * Returns VM_SUCCESS, if successful. - * Returns VM_FAILURE, if unsuccessful. */ - s32 commit_page_memory(void* pointer, size_t page_size); + void commit_page_memory(void* pointer, size_t page_size); /** * Free memory alloced via reserve_memory. - * - * Returns VM_SUCCESS, if successful. - * Returns VM_FAILURE, if unsuccessful. */ - s32 free_reserved_memory(void* pointer, size_t size); + void free_reserved_memory(void* pointer, size_t size); } \ No newline at end of file diff --git a/Utilities/rPlatform.cpp b/Utilities/rPlatform.cpp index 09ad275522..1b21be5b6c 100644 --- a/Utilities/rPlatform.cpp +++ b/Utilities/rPlatform.cpp @@ -10,6 +10,7 @@ #ifndef _WIN32 #include +#include #endif #include "rPlatform.h" @@ -57,14 +58,9 @@ std::string rPlatform::getConfigDir() dir = "./config"; dir = dir + "/rpcs3/"; - s32 ret = mkdir(dir.c_str(), 0777); - if (ret == EEXIST) + if (mkdir(dir.c_str(), 0777) == -1) { - LOG_WARNING(HLE, "Configuration directory already exists. (%s)", dir); - } - else if (ret < 0) - { - LOG_ERROR(HLE, "An error occured during the creation of the configuration directory. (%d)", ret); + printf("An error occured during the creation of the configuration directory. (%d)", errno); } #endif } diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 134697e67c..011e9a701f 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -172,12 +172,8 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD { metadata_sec_offset = metadata_offset + (unsigned long long) i * metadata_section_size; - if (in->seek(metadata_sec_offset) < 0) - { - LOG_ERROR(LOADER, "EDAT: Seeking medata section offset at %u failed.", metadata_sec_offset); - return 1; - } - + CHECK_ASSERTION(in->seek(metadata_sec_offset) != -1); + unsigned char metadata[0x20]; memset(metadata, 0, 0x20); in->read(metadata, 0x20); @@ -205,7 +201,7 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD { // If FLAG 0x20, the metadata precedes each data block. metadata_sec_offset = metadata_offset + (unsigned long long) i * (metadata_section_size + length); - in->seek(metadata_sec_offset); + CHECK_ASSERTION(in->seek(metadata_sec_offset) != -1); unsigned char metadata[0x20]; memset(metadata, 0, 0x20); @@ -226,7 +222,7 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD else { metadata_sec_offset = metadata_offset + (unsigned long long) i * metadata_section_size; - in->seek(metadata_sec_offset); + CHECK_ASSERTION(in->seek(metadata_sec_offset) != -1); in->read(hash_result, 0x10); offset = metadata_offset + (unsigned long long) i * edat->block_size + (unsigned long long) block_num * metadata_section_size; @@ -248,11 +244,7 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD memset(hash, 0, 0x10); memset(key_result, 0, 0x10); - if (in->seek(offset) < 0) - { - LOG_ERROR(LOADER, "EDAT: Seeking offset at %u failed.", offset); - return 1; - } + CHECK_ASSERTION(in->seek(offset) != -1); in->read(enc_data, length); @@ -357,7 +349,7 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs::file* f, bool verbose) { - f->seek(0); + CHECK_ASSERTION(f->seek(0) != -1); unsigned char header[0xA0]; unsigned char empty_header[0xA0]; unsigned char header_hash[0x10]; @@ -402,10 +394,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs: f->read(header, 0xA0); // Read in the header and metadata section hashes. - if (f->seek(0x90) < 0) - { - LOG_ERROR(LOADER, "EDAT: Seeking header at 0x90 failed."); - } + CHECK_ASSERTION(f->seek(0x90) != -1); f->read(metadata_hash, 0x10); f->read(header_hash, 0x10); @@ -462,10 +451,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs: while (bytes_to_read > 0) { // Locate the metadata blocks. - if (f->seek(metadata_section_offset) < 0) - { - LOG_ERROR(LOADER, "EDAT: Seeking metadata blocks at %u failed.", metadata_section_offset); - } + CHECK_ASSERTION(f->seek(metadata_section_offset) != -1); // Read in the metadata. f->read(metadata + bytes_read, metadata_section_size); @@ -512,9 +498,9 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs: // Read in the metadata and header signatures. - f->seek(0xB0); + CHECK_ASSERTION(f->seek(0xB0) != -1); f->read(metadata_signature, 0x28); - f->seek(0xD8); + CHECK_ASSERTION(f->seek(0xD8) != -1); f->read(header_signature, 0x28); // Checking metadata signature. @@ -530,7 +516,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs: { int metadata_buf_size = block_num * 0x10; unsigned char *metadata_buf = new unsigned char[metadata_buf_size]; - f->seek(metadata_offset); + CHECK_ASSERTION(f->seek(metadata_offset) != -1); f->read(metadata_buf, metadata_buf_size); sha1(metadata_buf, metadata_buf_size, signature_hash); delete[] metadata_buf; @@ -563,7 +549,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs: // Setup header signature hash. memset(signature_hash, 0, 20); unsigned char *header_buf = new unsigned char[0xD8]; - f->seek(0x00); + CHECK_ASSERTION(f->seek(0x00) != -1); f->read(header_buf, 0xD8); sha1(header_buf, 0xD8, signature_hash ); delete[] header_buf; diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index fd8a899d7f..03168d734c 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -86,11 +86,7 @@ bool UnpackPKG(const fs::file& pkg_f, const std::string& dir, volatile f64& prog // Define decryption subfunction (`psp` arg selects the key for specific block) auto decrypt = [&](u64 offset, u64 size, bool psp) -> u64 { - if (pkg_f.seek(start_offset + header.data_offset + offset) < 0) - { - LOG_ERROR(LOADER, "PKG: Package file seek to %u failed.", start_offset + header.data_offset + offset); - return -1; - } + CHECK_ASSERTION(pkg_f.seek(start_offset + header.data_offset + offset) != -1); // Read the data and set available size const u64 read = pkg_f.read(buf.get(), size); diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 036dc759dc..c307a9de6b 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -698,7 +698,7 @@ SELFDecrypter::SELFDecrypter(vfsStream& s) bool SELFDecrypter::LoadHeaders(bool isElf32) { // Read SCE header. - self_f.Seek(0); + CHECK_ASSERTION(self_f.Seek(0) != -1); sce_hdr.Load(self_f); // Check SCE magic. @@ -712,11 +712,12 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) self_hdr.Load(self_f); // Read the APP INFO. - self_f.Seek(self_hdr.se_appinfooff); + CHECK_ASSERTION(self_f.Seek(self_hdr.se_appinfooff) != -1); app_info.Load(self_f); // Read ELF header. - self_f.Seek(self_hdr.se_elfoff); + CHECK_ASSERTION(self_f.Seek(self_hdr.se_elfoff) != -1); + if (isElf32) elf32_hdr.Load(self_f); else @@ -741,13 +742,16 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) else { phdr64_arr.clear(); - if(elf64_hdr.e_phoff == 0 && elf64_hdr.e_phnum) + + if (elf64_hdr.e_phoff == 0 && elf64_hdr.e_phnum) { LOG_ERROR(LOADER, "SELF: ELF program header offset is null!"); return false; } - self_f.Seek(self_hdr.se_phdroff); - for(u32 i = 0; i < elf64_hdr.e_phnum; ++i) + + CHECK_ASSERTION(self_f.Seek(self_hdr.se_phdroff) != -1); + + for (u32 i = 0; i < elf64_hdr.e_phnum; ++i) { phdr64_arr.emplace_back(); phdr64_arr.back().Load(self_f); @@ -757,7 +761,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) // Read section info. secinfo_arr.clear(); - self_f.Seek(self_hdr.se_secinfoff); + CHECK_ASSERTION(self_f.Seek(self_hdr.se_secinfoff) != -1); for(u32 i = 0; i < ((isElf32) ? elf32_hdr.e_phnum : elf64_hdr.e_phnum); ++i) { @@ -766,12 +770,12 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) } // Read SCE version info. - self_f.Seek(self_hdr.se_sceveroff); + CHECK_ASSERTION(self_f.Seek(self_hdr.se_sceveroff) != -1); scev_info.Load(self_f); // Read control info. ctrlinfo_arr.clear(); - self_f.Seek(self_hdr.se_controloff); + CHECK_ASSERTION(self_f.Seek(self_hdr.se_controloff) != -1); u32 i = 0; while(i < self_hdr.se_controlsize) @@ -786,12 +790,15 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) if (isElf32) { shdr32_arr.clear(); - if(elf32_hdr.e_shoff == 0 && elf32_hdr.e_shnum) + + if (elf32_hdr.e_shoff == 0 && elf32_hdr.e_shnum) { LOG_WARNING(LOADER, "SELF: ELF section header offset is null!"); return true; } - self_f.Seek(self_hdr.se_shdroff); + + CHECK_ASSERTION(self_f.Seek(self_hdr.se_shdroff) != -1); + for(u32 i = 0; i < elf32_hdr.e_shnum; ++i) { shdr32_arr.emplace_back(); @@ -801,12 +808,14 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) else { shdr64_arr.clear(); - if(elf64_hdr.e_shoff == 0 && elf64_hdr.e_shnum) + if (elf64_hdr.e_shoff == 0 && elf64_hdr.e_shnum) { LOG_WARNING(LOADER, "SELF: ELF section header offset is null!"); return true; } - self_f.Seek(self_hdr.se_shdroff); + + CHECK_ASSERTION(self_f.Seek(self_hdr.se_shdroff) != -1); + for(u32 i = 0; i < elf64_hdr.e_shnum; ++i) { shdr64_arr.emplace_back(); @@ -890,9 +899,8 @@ bool SELFDecrypter::DecryptNPDRM(u8 *metadata, u32 metadata_size) memcpy(klicensee_key, key_v.GetKlicenseeKey(), 0x10); // Use klicensee if available. - // FIXME: Check is always false. - /*if (klicensee_key != NULL) - memcpy(npdrm_key, klicensee_key, 0x10);*/ + if (klicensee_key != NULL) + memcpy(npdrm_key, klicensee_key, 0x10); if (ctrl->npdrm.license == 1) // Network license. { @@ -942,11 +950,11 @@ bool SELFDecrypter::LoadMetadata() u8 *metadata_headers = (u8 *)malloc(metadata_headers_size); // Locate and read the encrypted metadata info. - self_f.Seek(sce_hdr.se_meta + sizeof(sce_hdr)); + CHECK_ASSERTION(self_f.Seek(sce_hdr.se_meta + sizeof(sce_hdr)) != -1); self_f.Read(metadata_info, metadata_info_size); // Locate and read the encrypted metadata header and section header. - self_f.Seek(sce_hdr.se_meta + sizeof(sce_hdr) + metadata_info_size); + CHECK_ASSERTION(self_f.Seek(sce_hdr.se_meta + sizeof(sce_hdr) + metadata_info_size) != -1); self_f.Read(metadata_headers, metadata_headers_size); // Find the right keyset from the key vault. @@ -1049,7 +1057,7 @@ bool SELFDecrypter::DecryptData() u8 *buf = (u8 *)malloc(meta_shdr[i].data_size); // Seek to the section data offset and read the encrypted data. - self_f.Seek(meta_shdr[i].data_offset); + CHECK_ASSERTION(self_f.Seek(meta_shdr[i].data_offset) != -1); self_f.Read(buf, meta_shdr[i].data_size); // Zero out our ctr nonce. @@ -1104,11 +1112,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32) if (meta_shdr[i].type == 2) { // Seek to the program header data offset and write the data. - if (e.seek(phdr32_arr[meta_shdr[i].program_idx].p_offset) < 0) - { - LOG_ERROR(LOADER, "MakeElf program header data seek to %u failed.", phdr32_arr[meta_shdr[i].program_idx].p_offset); - return false; - } + CHECK_ASSERTION(e.seek(phdr32_arr[meta_shdr[i].program_idx].p_offset) != -1); e.write(data_buf + data_buf_offset, meta_shdr[i].data_size); @@ -1120,11 +1124,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32) // Write section headers. if (self_hdr.se_shdroff != 0) { - if (e.seek(elf32_hdr.e_shoff) < 0) - { - LOG_ERROR(LOADER, "MakeElf section header seek to %u failed.", elf32_hdr.e_shoff); - return false; - } + CHECK_ASSERTION(e.seek(elf32_hdr.e_shoff) != -1); for (u32 i = 0; i < elf32_hdr.e_shnum; ++i) { @@ -1168,11 +1168,8 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32) decomp_stream_out.CopyTo(decomp_buf, phdr64_arr[meta_shdr[i].program_idx].p_filesz); // Seek to the program header data offset and write the data. - if (e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset) < 0) - { - LOG_ERROR(LOADER, "MakeElf program header data seek to %u failed.", phdr64_arr[meta_shdr[i].program_idx].p_offset); - return false; - } + + CHECK_ASSERTION(e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset) != -1); e.write(decomp_buf, phdr64_arr[meta_shdr[i].program_idx].p_filesz); @@ -1182,11 +1179,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32) else { // Seek to the program header data offset and write the data. - if (e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset) < 0) - { - LOG_ERROR(LOADER, "MakeElf program header data seek to %u failed.", phdr64_arr[meta_shdr[i].program_idx].p_offset); - return false; - } + CHECK_ASSERTION(e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset) != -1); e.write(data_buf + data_buf_offset, meta_shdr[i].data_size); } @@ -1199,11 +1192,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32) // Write section headers. if (self_hdr.se_shdroff != 0) { - if (e.seek(elf64_hdr.e_shoff) < 0) - { - LOG_ERROR(LOADER, "MakeElf section header seek to %u failed.", elf64_hdr.e_shoff); - return false; - } + CHECK_ASSERTION(e.seek(elf64_hdr.e_shoff) != -1); for (u32 i = 0; i < elf64_hdr.e_shnum; ++i) { @@ -1279,11 +1268,7 @@ bool IsSelfElf32(const std::string& path) // Locate the class byte and check it. u8 elf_class[0x8]; - if (f.Seek(sh.se_elfoff) < 0) - { - LOG_ERROR(LOADER, "IsSelfElf32 seek to %u failed.", sh.se_elfoff); - return false; - } + CHECK_ASSERTION(f.Seek(sh.se_elfoff) != -1); f.Read(elf_class, 0x8); @@ -1302,11 +1287,7 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf) } // Get the key version. - if (s.seek(0x08) < 0) - { - LOG_ERROR(LOADER, "Seeking debug (S)ELF at 0x08 failed."); - return false; - } + CHECK_ASSERTION(s.seek(0x08) != -1); u16 key_version; s.read(&key_version, sizeof(key_version)); @@ -1317,11 +1298,7 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf) LOG_WARNING(LOADER, "Debug SELF detected! Removing fake header..."); // Get the real elf offset. - if (s.seek(0x10) < 0) - { - LOG_ERROR(LOADER, "Seeking debug (S)ELF at 0x10 failed."); - return false; - } + CHECK_ASSERTION(s.seek(0x10) != -1); u64 elf_offset; s.read(&elf_offset, sizeof(elf_offset)); @@ -1329,11 +1306,7 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf) // Start at the real elf offset. elf_offset = swap64(elf_offset); - if (s.seek(elf_offset) < 0) - { - LOG_ERROR(LOADER, "Seeking debug (S)ELF at %u failed.", elf_offset); - return false; - } + CHECK_ASSERTION(s.seek(elf_offset) != -1); // Write the real ELF file back. fs::file e(elf, fom::write | fom::create | fom::trunc); diff --git a/rpcs3/Emu/HDD/HDD.cpp b/rpcs3/Emu/HDD/HDD.cpp index 4a5ca5e798..769f2ebf43 100644 --- a/rpcs3/Emu/HDD/HDD.cpp +++ b/rpcs3/Emu/HDD/HDD.cpp @@ -19,7 +19,7 @@ void vfsHDDManager::CreateEntry(vfsHDD_Entry& entry) CreateBlock(entry); } -s32 vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size) +void vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size) { fs::file f(path, fom::write | fom::create | fom::trunc); @@ -48,15 +48,9 @@ s32 vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size) u8 null = 0; - if (f.seek(hdr.block_count * hdr.block_size - sizeof(null)) < HDD_OK) - { - LOG_ERROR(HLE, "CreateHDD seek to %u failed.", hdr.block_count * hdr.block_size - sizeof(null)); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(f.seek(hdr.block_count * hdr.block_size - sizeof(null)) != -1); f.write(&null, sizeof(null)); - - return HDD_OK; } void vfsHDDManager::Format() @@ -76,11 +70,7 @@ bool vfsHDDFile::goto_block(u64 n) return false; } - if (m_hdd.Seek(m_info.data_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "goto_block seek to %u failed.", m_info.data_block * m_hdd_info.block_size); - return false; - } + CHECK_ASSERTION(m_hdd.Seek(m_info.data_block * m_hdd_info.block_size) != -1); block_info.next_block = m_info.data_block; @@ -91,11 +81,7 @@ bool vfsHDDFile::goto_block(u64 n) return false; } - if (m_hdd.Seek(block_info.next_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "goto_block seek to %u failed.", block_info.next_block * m_hdd_info.block_size); - return false; - } + CHECK_ASSERTION(m_hdd.Seek(block_info.next_block * m_hdd_info.block_size) != -1); m_hdd.Read(&block_info, sizeof(vfsHDD_Block)); } @@ -117,99 +103,57 @@ void vfsHDDFile::RemoveBlocks(u64 start_block) } } -s32 vfsHDDFile::WriteBlock(u64 block, const vfsHDD_Block& data) +void vfsHDDFile::WriteBlock(u64 block, const vfsHDD_Block& data) { - if (m_hdd.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "WriteBlock seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size) != -1); m_hdd.Write(&data, sizeof(vfsHDD_Block)); - - return HDD_OK; } -s32 vfsHDDFile::ReadBlock(u64 block, vfsHDD_Block& data) +void vfsHDDFile::ReadBlock(u64 block, vfsHDD_Block& data) { - if (m_hdd.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "ReadBlock seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size) != -1); m_hdd.Read(&data, sizeof(vfsHDD_Block)); - - return HDD_OK; } -s32 vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data) +void vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data) { - if (m_hdd.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size) != -1); m_hdd.Write(&data, sizeof(vfsHDD_Entry)); - - return HDD_OK; } -s32 vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data) +void vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data) { - if (m_hdd.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size) != -1); m_hdd.Read(&data, sizeof(vfsHDD_Entry)); - - return HDD_OK; } -s32 vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name) +void vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name) { - if (m_hdd.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size) != -1); m_hdd.Read(&data, sizeof(vfsHDD_Entry)); name.resize(GetMaxNameLen()); m_hdd.Read(&name.front(), GetMaxNameLen()); - - return HDD_OK; } -s32 vfsHDDFile::ReadEntry(u64 block, std::string& name) +void vfsHDDFile::ReadEntry(u64 block, std::string& name) { - if (m_hdd.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)) < HDD_OK) - { - LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)) != -1); name.resize(GetMaxNameLen()); m_hdd.Read(&name.front(), GetMaxNameLen()); - - return HDD_OK; } -s32 vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name) +void vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name) { - if (m_hdd.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(block * m_hdd_info.block_size) != -1); m_hdd.Write(&data, sizeof(vfsHDD_Entry)); m_hdd.Write(name.c_str(), std::min(GetMaxNameLen() - 1, name.length() + 1)); - - return HDD_OK; } void vfsHDDFile::Open(u64 info_block) @@ -248,19 +192,13 @@ bool vfsHDDFile::Seek(u64 pos) return true; } -s32 vfsHDDFile::SaveInfo() +void vfsHDDFile::SaveInfo() { - m_hdd.Seek(m_info_block * m_hdd_info.block_size); + CHECK_ASSERTION(m_hdd.Seek(m_info_block * m_hdd_info.block_size) != -1); - if (m_hdd.Seek(m_info_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "SaveInfo seek to %u failed.", m_info_block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(m_info_block * m_hdd_info.block_size) != -1); m_hdd.Write(&m_info, sizeof(vfsHDD_Entry)); - - return HDD_OK; } u64 vfsHDDFile::Read(void* dst, u64 size) @@ -275,19 +213,11 @@ u64 vfsHDDFile::Read(void* dst, u64 size) vfsHDD_Block cur_block_info; - if (m_hdd.Seek(m_cur_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "Read seek to %u failed.", m_cur_block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(m_cur_block * m_hdd_info.block_size) != -1); m_hdd.Read(&cur_block_info, sizeof(vfsHDD_Block)); - if (m_hdd.Seek(m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position) < HDD_OK) - { - LOG_ERROR(HLE, "Read seek to %u failed.", m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position) != -1); m_hdd.Read(dst, rsize); size -= rsize; @@ -309,11 +239,7 @@ u64 vfsHDDFile::Read(void* dst, u64 size) m_cur_block = cur_block_info.next_block; rsize = std::min(block_size, size); - if (m_hdd.Seek(cur_block_info.next_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "Read seek to %u failed.", cur_block_info.next_block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(cur_block_info.next_block * m_hdd_info.block_size) != -1); m_hdd.Read(&cur_block_info, sizeof(vfsHDD_Block)); @@ -365,11 +291,7 @@ u64 vfsHDDFile::Write(const void* src, u64 size) if (wsize) { - if (m_hdd.Seek(m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position) < HDD_OK) - { - LOG_ERROR(HLE, "Write seek to %u failed.", m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position) != -1); m_hdd.Write(src, wsize); size -= wsize; @@ -401,11 +323,7 @@ u64 vfsHDDFile::Write(const void* src, u64 size) block_info.next_block = m_cur_block; - if (m_hdd.Seek(last_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "Write seek to %u failed.", last_block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(last_block * m_hdd_info.block_size) != -1); if (m_hdd.Write(&block_info, sizeof(vfsHDD_Block)) != sizeof(vfsHDD_Block)) { @@ -416,11 +334,7 @@ u64 vfsHDDFile::Write(const void* src, u64 size) block_info.next_block = 0; - if (m_hdd.Seek(m_cur_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "Write seek to %u failed.", m_cur_block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd.Seek(m_cur_block * m_hdd_info.block_size) != -1); if (m_hdd.Write(&block_info, sizeof(vfsHDD_Block)) != sizeof(vfsHDD_Block)) { @@ -473,11 +387,7 @@ vfsHDD::vfsHDD(vfsDevice* device, const std::string& hdd_path) m_hdd_info.block_size = 2048; } - if (m_hdd_file.Seek(m_cur_dir_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "vfsHDD initialization seek to %u failed.", m_cur_dir_block * m_hdd_info.block_size); - return; - } + CHECK_ASSERTION(m_hdd_file.Seek(m_cur_dir_block * m_hdd_info.block_size) != -1); m_hdd_file.Read(&m_cur_dir, sizeof(vfsHDD_Entry)); } @@ -513,27 +423,26 @@ s32 vfsHDD::OpenDir(const std::string& name) { LOG_WARNING(HLE, "OpenDir(%s)", name.c_str()); u64 entry_block; + if (!SearchEntry(name, entry_block)) { - LOG_ERROR(HLE, "OpenDir could not find the entry. (%s)", name); - return HDD_ENTRY_NOT_FOUND; + return -1; } - if (m_hdd_file.Seek(entry_block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "OpenDir seek to %u failed.", entry_block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(entry_block * m_hdd_info.block_size) != -1); vfsHDD_Entry entry; m_hdd_file.Read(&entry, sizeof(vfsHDD_Entry)); + if (entry.type == vfsHDD_Entry_File) + { return 1; + } m_cur_dir_block = entry.data_block; ReadEntry(m_cur_dir_block, m_cur_dir); - return HDD_OK; + return 0; } bool vfsHDD::Rename(const std::string& from, const std::string& to) @@ -568,99 +477,57 @@ u64 vfsHDD::FindFreeBlock() return 0; } -s32 vfsHDD::WriteBlock(u64 block, const vfsHDD_Block& data) +void vfsHDD::WriteBlock(u64 block, const vfsHDD_Block& data) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "WriteBlock seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size) != -1); m_hdd_file.Write(&data, sizeof(vfsHDD_Block)); - - return HDD_OK; } -s32 vfsHDD::ReadBlock(u64 block, vfsHDD_Block& data) +void vfsHDD::ReadBlock(u64 block, vfsHDD_Block& data) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "ReadBlock seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size) != -1); m_hdd_file.Read(&data, sizeof(vfsHDD_Block)); - - return HDD_OK; } -s32 vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data) +void vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size) != -1); m_hdd_file.Write(&data, sizeof(vfsHDD_Entry)); - - return HDD_OK; } -s32 vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data) +void vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size) != -1); m_hdd_file.Read(&data, sizeof(vfsHDD_Entry)); - - return HDD_OK; } -s32 vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name) +void vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size) != -1); m_hdd_file.Read(&data, sizeof(vfsHDD_Entry)); name.resize(GetMaxNameLen()); m_hdd_file.Read(&name.front(), GetMaxNameLen()); - - return HDD_OK; } -s32 vfsHDD::ReadEntry(u64 block, std::string& name) +void vfsHDD::ReadEntry(u64 block, std::string& name) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)) < HDD_OK) - { - LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)) != -1); name.resize(GetMaxNameLen()); m_hdd_file.Read(&name.front(), GetMaxNameLen()); - - return HDD_OK; } -s32 vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name) +void vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name) { - if (m_hdd_file.Seek(block * m_hdd_info.block_size) < HDD_OK) - { - LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size); - return HDD_SEEK_FAILURE; - } + CHECK_ASSERTION(m_hdd_file.Seek(block * m_hdd_info.block_size) != -1); m_hdd_file.Write(&data, sizeof(vfsHDD_Entry)); m_hdd_file.Write(name.c_str(), std::min(GetMaxNameLen() - 1, name.length() + 1)); - - return HDD_OK; } bool vfsHDD::Create(vfsHDD_EntryType type, const std::string& name) @@ -793,13 +660,13 @@ bool vfsHDD::Open(const std::string& path, u32 mode) { if (pos - from > 1) { - int res = OpenDir(std::string(s + from, pos)); + s32 res = OpenDir(std::string(s + from, pos)); + if (res == -1) { return false; } - - if (res == 1) + else if (res == 1) { file_pos = from; } diff --git a/rpcs3/Emu/HDD/HDD.h b/rpcs3/Emu/HDD/HDD.h index ff8fc476df..9bbc651f23 100644 --- a/rpcs3/Emu/HDD/HDD.h +++ b/rpcs3/Emu/HDD/HDD.h @@ -5,14 +5,6 @@ static const u64 g_hdd_magic = *(u64*)"PS3eHDD\0"; static const u16 g_hdd_version = 0x0001; -// Return codes -enum -{ - HDD_OK = 0, - HDD_SEEK_FAILURE = 0x400, - HDD_ENTRY_NOT_FOUND = 0x401, -}; - struct vfsHDD_Block { struct @@ -55,7 +47,7 @@ public: static void CreateEntry(vfsHDD_Entry& entry); - static s32 CreateHDD(const std::string& path, u64 size, u64 block_size); + static void CreateHDD(const std::string& path, u64 size, u64 block_size); void Format(); @@ -76,19 +68,19 @@ class vfsHDDFile void RemoveBlocks(u64 start_block); - s32 WriteBlock(u64 block, const vfsHDD_Block& data); + void WriteBlock(u64 block, const vfsHDD_Block& data); - s32 ReadBlock(u64 block, vfsHDD_Block& data); + void ReadBlock(u64 block, vfsHDD_Block& data); - s32 WriteEntry(u64 block, const vfsHDD_Entry& data); + void WriteEntry(u64 block, const vfsHDD_Entry& data); - s32 ReadEntry(u64 block, vfsHDD_Entry& data); + void ReadEntry(u64 block, vfsHDD_Entry& data); - s32 ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name); + void ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name); - s32 ReadEntry(u64 block, std::string& name); + void ReadEntry(u64 block, std::string& name); - s32 WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name); + void WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name); force_inline u32 GetMaxNameLen() const { @@ -122,7 +114,7 @@ public: return m_cur_block * m_hdd_info.block_size + m_position; // ??? } - s32 SaveInfo(); + void SaveInfo(); u64 Read(void* dst, u64 size); @@ -170,19 +162,19 @@ public: u64 FindFreeBlock(); - s32 WriteBlock(u64 block, const vfsHDD_Block& data); + void WriteBlock(u64 block, const vfsHDD_Block& data); - s32 ReadBlock(u64 block, vfsHDD_Block& data); + void ReadBlock(u64 block, vfsHDD_Block& data); - s32 WriteEntry(u64 block, const vfsHDD_Entry& data); + void WriteEntry(u64 block, const vfsHDD_Entry& data); - s32 ReadEntry(u64 block, vfsHDD_Entry& data); + void ReadEntry(u64 block, vfsHDD_Entry& data); - s32 ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name); + void ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name); - s32 ReadEntry(u64 block, std::string& name); + void ReadEntry(u64 block, std::string& name); - s32 WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name); + void WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name); bool Create(vfsHDD_EntryType type, const std::string& name); diff --git a/rpcs3/Emu/Memory/MemoryBlock.h b/rpcs3/Emu/Memory/MemoryBlock.h index 1f1df7d848..113f4835d1 100644 --- a/rpcs3/Emu/Memory/MemoryBlock.h +++ b/rpcs3/Emu/Memory/MemoryBlock.h @@ -87,7 +87,7 @@ public: if (!getRealAddr(addr, realAddr)) { - LOG_ERROR(HLE, "Getting the real address failed. (addr=%u)", addr); + LOG_ERROR(HLE, "Getting the real address failed. (addr=0x%x)", addr); return 0; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index c2c36a3c81..232771d4b6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -265,11 +265,11 @@ s32 cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 buffer_size, const auto old_position = file->file->Tell(); - file->file->Seek(offset); + CHECK_ASSERTION(file->file->Seek(offset) != -1); const auto read = file->file->Read(buf.get_ptr(), buffer_size); - file->file->Seek(old_position); + CHECK_ASSERTION(file->file->Seek(old_position) != -1); if (nread) { @@ -296,11 +296,11 @@ s32 cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr buf, u64 data_size, const auto old_position = file->file->Tell(); - file->file->Seek(offset); + CHECK_ASSERTION(file->file->Seek(offset) != -1); const auto written = file->file->Write(buf.get_ptr(), data_size); - file->file->Seek(old_position); + CHECK_ASSERTION(file->file->Seek(old_position) != -1); if (nwrite) { @@ -508,9 +508,9 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size) // read data auto old = file->file->Tell(); - file->file->Seek(offset + file->st_total_read); + CHECK_ASSERTION(file->file->Seek(offset + file->st_total_read) != -1); auto res = file->file->Read(vm::base(position), file->st_block_size); - file->file->Seek(old); + CHECK_ASSERTION(file->file->Seek(old) != -1); // notify file->st_total_read += res; @@ -803,17 +803,27 @@ s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil } if (flags & 0x20) - packed_stream->Seek(0x100); + { + CHECK_ASSERTION(packed_stream->Seek(0x100) != -1); + } else - packed_stream->Seek(startOffset); + { + CHECK_ASSERTION(packed_stream->Seek(startOffset) != -1); + } for (u32 i = 0; i < blockCount; i++) { if (flags & 0x20) - packed_stream->Seek(packed_stream->Tell() + t1); + { + s64 cur; + CHECK_ASSERTION((cur = packed_stream->Tell()) != -1); + CHECK_ASSERTION(packed_stream->Seek(cur + t1) != -1); + } if (!(blockCount - i - 1)) + { blockSize = (u32)(filesizeOutput - i * blockSize); + } packed_stream->Read(buffer + 256, blockSize); unpacked_stream->Write(buffer + 256, blockSize); @@ -883,11 +893,11 @@ void fsAio(vm::ptr aio, bool write, s32 xid, fs_aio_cb_t func) const auto old_position = file->file->Tell(); - file->file->Seek(aio->offset); + CHECK_ASSERTION(file->file->Seek(aio->offset) != -1); result = write ? file->file->Write(aio->buf.get_ptr(), aio->size) : file->file->Read(aio->buf.get_ptr(), aio->size); - file->file->Seek(old_position); + CHECK_ASSERTION(file->file->Seek(old_position) != -1); } // should be executed directly by FS AIO thread diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 7d77a9adb2..03812a55cf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -344,17 +344,14 @@ s32 CalculateSurfaceByteSize(u32 mode, CellRescDsts *dsts) s32 CalculateMaxColorBuffersSize() { - s32 index, oneBufSize, bufNum, totalBufSize, maxBufSize; + s32 oneBufSize, bufNum, totalBufSize, maxBufSize; maxBufSize = 0; for (u32 bufMode = CELL_RESC_720x480; bufMode <= CELL_RESC_1920x1080; bufMode <<= 1) { if (s_rescInternalInstance->m_initConfig.supportModes & bufMode) { - if ((index = GetRescDestsIndex(bufMode)) != 0) - { - oneBufSize = CalculateSurfaceByteSize(bufMode, &(s_rescInternalInstance->m_rescDsts[index])); - } + oneBufSize = CalculateSurfaceByteSize(bufMode, &(s_rescInternalInstance->m_rescDsts[GetRescDestsIndex(bufMode)])); bufNum = cellRescGetNumColorBuffers(bufMode, s_rescInternalInstance->m_initConfig.palTemporalMode, 0); totalBufSize = oneBufSize * bufNum; maxBufSize = (maxBufSize > totalBufSize) ? maxBufSize : totalBufSize; diff --git a/rpcs3/Gui/AutoPauseManager.cpp b/rpcs3/Gui/AutoPauseManager.cpp index 6e31e05f77..fd3abd43a1 100644 --- a/rpcs3/Gui/AutoPauseManager.cpp +++ b/rpcs3/Gui/AutoPauseManager.cpp @@ -79,7 +79,7 @@ void AutoPauseManagerDialog::LoadEntries(void) u32 num; size_t fmax = list.size(); size_t fcur = 0; - list.seek(0); + CHECK_ASSERTION(list.seek(0) != -1); while (fcur <= fmax - sizeof(u32)) { list.read(&num, sizeof(u32)); @@ -99,7 +99,7 @@ void AutoPauseManagerDialog::SaveEntries(void) fs::file list("pause.bin", fom::write | fom::create | fom::trunc); //System calls ID and Function calls ID are all u32 iirc. u32 num = 0; - list.seek(0); + CHECK_ASSERTION(list.seek(0) != -1); for (size_t i = 0; i < m_entries.size(); ++i) { if (num == 0xFFFFFFFF) continue; diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 16ef7877b9..5d5c96e546 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -263,11 +263,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) // Fetch title ID from the header char title_id[10] = "?????????"; - if (!pkg_f.seek(55)) - { - LOG_ERROR(LOADER, "PKG: Failed to seek offset 55."); - return; - } + CHECK_ASSERTION(pkg_f.seek(55) != -1); pkg_f.read(title_id, 9); pkg_f.seek(0);