diff --git a/Utilities/File.cpp b/Utilities/File.cpp index ba7859034e..65731286cf 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -304,7 +304,7 @@ std::shared_ptr fs::device_manager::set_device(const std::strin std::shared_ptr fs::get_virtual_device(const std::string& path) { // Every virtual device path must have "//" at the beginning - if (path.size() > 2 && reinterpret_cast(path.front()) == "//"_u16) + if (path.starts_with("//")) { return get_device_manager().get_device(path); } @@ -314,7 +314,7 @@ std::shared_ptr fs::get_virtual_device(const std::string& path) std::shared_ptr fs::set_virtual_device(const std::string& name, const std::shared_ptr& device) { - verify(HERE), name.size() > 2, name[0] == '/', name[1] == '/', name.find('/', 2) == -1; + verify(HERE), name.starts_with("//"), name[2] != '/'; return get_device_manager().set_device(name, device); } @@ -338,7 +338,7 @@ std::string fs::get_parent_dir(const std::string& path) if (std::exchange(last, pos - 1) != pos) { // Return empty string if the path doesn't contain at least 2 elements - return path.substr(0, pos != -1 && path.find_last_not_of(delim, pos, sizeof(delim) - 1) != -1 ? pos : 0); + return path.substr(0, pos != umax && path.find_last_not_of(delim, pos, sizeof(delim) - 1) != umax ? pos : 0); } } } diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index e13df1ce73..ba008ee4d6 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -80,7 +80,7 @@ static u8* add_jit_memory(std::size_t size, uint align) return _pos; }); - if (pos == -1) [[unlikely]] + if (pos == umax) [[unlikely]] { jit_log.warning("JIT: Out of memory (size=0x%x, align=0x%x, off=0x%x)", size, align, Off); return nullptr; diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 086f95f83c..ccc5721969 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -464,7 +464,7 @@ logs::file_writer::file_writer(const std::string& name) if (!flush(bufv)) { - if (m_out == -1) + if (m_out == umax) { break; } diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 5fbf5ec6ba..5b99eb38f2 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1389,7 +1389,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no error_code sending_error = sys_event_port_send(pf_port_id, data1, data2, data3); // If we fail due to being busy, wait a bit and try again. - while (sending_error == CELL_EBUSY) + while (static_cast(sending_error) == CELL_EBUSY) { if (cpu->id_type() == 1) { @@ -1411,7 +1411,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no vm_log.fatal("Unknown error %x while trying to pass page fault.", +sending_error); cpu->state += cpu_flag::dbg_pause; } - + // Wait until the thread is recovered for (std::shared_lock pf_lock(pf_events->pf_mutex); pf_events->events.count(static_cast(data2)) && !sending_error;) diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 3edb7bff52..e320e58ab7 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -324,7 +324,7 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD in->seek(0); memset(data.get(), 0, edat->block_size); u64 res = decrypt_block(in, data.get(), edat, npd, crypt_key, i, total_blocks, size_left); - if (res == -1) + if (res == umax) { edat_log.error("EDAT: Decrypt Block failed!"); return 1; @@ -966,7 +966,7 @@ u64 EDATADecrypter::ReadData(u64 pos, u8* data, u64 size) { edata_file.seek(0); u64 res = decrypt_block(&edata_file, &data_buf[writeOffset], &edatHeader, &npdHeader, dec_key.data(), i, total_blocks, edatHeader.file_size); - if (res == -1) + if (res == umax) { edat_log.error("Error Decrypting data"); return 0; diff --git a/rpcs3/Emu/Audio/ALSA/ALSABackend.cpp b/rpcs3/Emu/Audio/ALSA/ALSABackend.cpp index dc436ee6c6..a54be5e3f1 100644 --- a/rpcs3/Emu/Audio/ALSA/ALSABackend.cpp +++ b/rpcs3/Emu/Audio/ALSA/ALSABackend.cpp @@ -155,7 +155,7 @@ bool ALSABackend::AddData(const void* src, u32 num_samples) return false; } - if (res != num_frames) + if (res + 0u != num_frames) { ALSA.warning("Error (%d)", res); return false; diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp index 2ca1fa62f2..e3c608bfc6 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp @@ -443,7 +443,7 @@ error_code cellFsReadWithOffset(ppu_thread& ppu, u32 fd, u64 offset, vm::ptrout_size.value(); + *nread = rc && rc + 0u != CELL_EFSSPECIFIC ? 0 : arg->out_size.value(); } if (!rc && arg->out_code) @@ -485,7 +485,7 @@ error_code cellFsWriteWithOffset(ppu_thread& ppu, u32 fd, u64 offset, vm::cptrout_size.value(); + *nwrite = rc && rc + 0u != CELL_EFSSPECIFIC ? 0 : arg->out_size.value(); } if (!rc && arg->out_code) diff --git a/rpcs3/Emu/Cell/Modules/cellL10n.cpp b/rpcs3/Emu/Cell/Modules/cellL10n.cpp index b6966cd9cf..08021ae9ca 100644 --- a/rpcs3/Emu/Cell/Modules/cellL10n.cpp +++ b/rpcs3/Emu/Cell/Modules/cellL10n.cpp @@ -237,7 +237,7 @@ s32 _ConvertStr(s32 src_code, const void *src, s32 src_len, s32 dst_code, void * size_t dstLen = *dst_len; size_t ictd = iconv(ict, const_cast(reinterpret_cast(&src)), &srcLen, reinterpret_cast(&dst), &dstLen); *dst_len -= dstLen; - if (ictd == -1) + if (ictd == umax) { if (errno == EILSEQ) retValue = SRCIllegal; //Invalid multi-byte sequence @@ -262,7 +262,7 @@ s32 _ConvertStr(s32 src_code, const void *src, s32 src_len, s32 dst_code, void * size_t bufLeft = sizeof(buf); size_t ictd = iconv(ict, const_cast(reinterpret_cast(&src)), &srcLen, reinterpret_cast(&dst), &bufLeft); *dst_len += sizeof(buf) - bufLeft; - if (ictd == -1 && errno != E2BIG) + if (ictd == umax && errno != E2BIG) { if (errno == EILSEQ) retValue = SRCIllegal; diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 4ac31df20f..5a959744e4 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -716,7 +716,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v { case CELL_SAVEDATA_FOCUSPOS_DIRNAME: { - for (s32 i = 0; i < save_entries.size(); i++) + for (u32 i = 0; i < save_entries.size(); i++) { if (save_entries[i].dirName == listSet->focusDirName.get_ptr()) { @@ -741,7 +741,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v { s64 max = INT64_MIN; - for (s32 i = 0; i < save_entries.size(); i++) + for (u32 i = 0; i < save_entries.size(); i++) { if (save_entries[i].mtime > max) { @@ -756,7 +756,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v { s64 min = INT64_MAX; - for (s32 i = 0; i < save_entries.size(); i++) + for (u32 i = 0; i < save_entries.size(); i++) { if (save_entries[i].mtime < min) { @@ -949,7 +949,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v return {CELL_SAVEDATA_ERROR_PARAM, "26"}; } - for (s32 i = 0; i < save_entries.size(); i++) + for (u32 i = 0; i < save_entries.size(); i++) { if (save_entries[i].dirName == fixedSet->dirName.get_ptr()) { @@ -1020,7 +1020,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v if (selected >= 0) { - if (selected < save_entries.size()) + if (selected + 0u < save_entries.size()) { save_entry.dirName = std::move(save_entries[selected].dirName); save_entry.escaped = vfs::escape(save_entry.dirName); @@ -1589,7 +1589,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v fs::remove_all(old_path); } - if (savedata_result == CELL_SAVEDATA_ERROR_CBRESULT) + if (savedata_result + 0u == CELL_SAVEDATA_ERROR_CBRESULT) { return display_callback_result_error_message(ppu, result, errDialog); } diff --git a/rpcs3/Emu/Cell/Modules/cellSearch.cpp b/rpcs3/Emu/Cell/Modules/cellSearch.cpp index 46d1ac15b8..e6db07352c 100644 --- a/rpcs3/Emu/Cell/Modules/cellSearch.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSearch.cpp @@ -60,7 +60,7 @@ struct search_info vm::ptr func; vm::ptr userData; - atomic_t state = search_state::not_initialized; + atomic_t state = search_state::not_initialized; shared_mutex links_mutex; std::unordered_map content_links; @@ -653,7 +653,7 @@ error_code cellSearchGetContentInfoByOffset(CellSearchId searchId, s32 offset, v return CELL_SEARCH_ERROR_GENERIC; } - if (offset >= 0 && offset < searchObject->content_ids.size()) + if (offset >= 0 && offset + 0u < searchObject->content_ids.size()) { const auto& content_id = searchObject->content_ids[offset]; const auto& content_info = content_id.second; @@ -842,7 +842,7 @@ error_code cellSearchGetContentIdByOffset(CellSearchId searchId, s32 offset, vm: return CELL_SEARCH_ERROR_GENERIC; } - if (offset > -1 && offset < searchObject->content_ids.size()) + if (offset >= 0 && offset + 0u < searchObject->content_ids.size()) { auto& content_id = searchObject->content_ids.at(offset); const u128 content_id_128 = content_id.first; diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index 6eae188178..79af78b067 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -20,18 +20,7 @@ LOG_CHANNEL(cellSpurs); error_code sys_spu_image_close(ppu_thread&, vm::ptr img); -// TODO -struct cell_error_t -{ - s32 value; - - explicit operator bool() const - { - return (value < 0); - } -}; - -#define CHECK_SUCCESS(expr) if (cell_error_t error{expr}) fmt::throw_exception("Failure: %s -> 0x%x" HERE, #expr, error.value) +#define CHECK_SUCCESS(expr) if (error_code error = (expr); error < 0) fmt::throw_exception("Failure: %s -> 0x%x" HERE, #expr, error.value) //---------------------------------------------------------------------------- // Function prototypes @@ -428,7 +417,7 @@ s32 _spurs::attach_lv2_eq(ppu_thread& ppu, vm::ptr spurs, u32 queue, if (s32 res = sys_spu_thread_group_connect_event_all_threads(ppu, spurs->spuTG, queue, portMask, port)) { - if (res == CELL_EISCONN) + if (res + 0u == CELL_EISCONN) { return CELL_SPURS_CORE_ERROR_BUSY; } @@ -577,7 +566,7 @@ void _spurs::handler_entry(ppu_thread& ppu, vm::ptr spurs) if (s32 rc = sys_spu_thread_group_join(ppu, spurs->spuTG, vm::var{}, vm::var{})) { - if (rc == CELL_ESTAT) + if (rc + 0u == CELL_ESTAT) { return sys_ppu_thread_exit(ppu, 0); } @@ -850,7 +839,7 @@ s32 _spurs::finalize_spu(ppu_thread& ppu, vm::ptr spurs) if (s32 rc = sys_spu_thread_group_destroy(ppu, spurs->spuTG)) { - if (rc == CELL_EBUSY) + if (rc + 0u == CELL_EBUSY) { continue; } @@ -2817,7 +2806,7 @@ s32 cellSpursEventFlagSet(ppu_thread& ppu, vm::ptr eventFlag } auto rc = _cellSpursSendSignal(ppu, *taskset, eventFlag->waitingTaskId[i]); - if (rc == CELL_SPURS_TASK_ERROR_INVAL || rc == CELL_SPURS_TASK_ERROR_STAT) + if (rc + 0u == CELL_SPURS_TASK_ERROR_INVAL || rc + 0u == CELL_SPURS_TASK_ERROR_STAT) { return CELL_SPURS_TASK_ERROR_FATAL; } @@ -3533,7 +3522,7 @@ s32 _spurs::task_start(ppu_thread& ppu, vm::ptr taskset, u32 t if (s32 rc = cellSpursWakeUp(ppu, taskset->spurs)) { - if (rc == CELL_SPURS_POLICY_MODULE_ERROR_STAT) + if (rc + 0u == CELL_SPURS_POLICY_MODULE_ERROR_STAT) { rc = CELL_SPURS_TASK_ERROR_STAT; } @@ -3610,7 +3599,7 @@ s32 _cellSpursSendSignal(ppu_thread& ppu, vm::ptr taskset, u32 { cellSpursSendWorkloadSignal(taskset->spurs, taskset->wid); auto rc = cellSpursWakeUp(ppu, taskset->spurs); - if (rc == CELL_SPURS_POLICY_MODULE_ERROR_STAT) + if (rc + 0u == CELL_SPURS_POLICY_MODULE_ERROR_STAT) { return CELL_SPURS_TASK_ERROR_STAT; } diff --git a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp index 717b1f5c70..ae90d03a3d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp @@ -262,7 +262,7 @@ bool spursKernel1SelectWorkload(spu_thread& spu) // Calculate the contention (number of SPUs used) for each workload u8 contention[CELL_SPURS_MAX_WORKLOAD]; u8 pendingContention[CELL_SPURS_MAX_WORKLOAD]; - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) { contention[i] = spurs->wklCurrentContention[i] - ctxt->wklLocContention[i]; @@ -296,7 +296,7 @@ bool spursKernel1SelectWorkload(spu_thread& spu) { // Caclulate the scheduling weight for each workload u16 maxWeight = 0; - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) { u16 runnable = ctxt->wklRunnable1 & (0x8000 >> i); u16 wklSignal = spurs->wklSignal1.load() & (0x8000 >> i); @@ -371,7 +371,7 @@ bool spursKernel1SelectWorkload(spu_thread& spu) contention[wklSelectedId]++; } - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) { spurs->wklCurrentContention[i] = contention[i]; spurs->wklPendingContention[i] = spurs->wklPendingContention[i] - ctxt->wklLocPendingContention[i]; @@ -395,7 +395,7 @@ bool spursKernel1SelectWorkload(spu_thread& spu) pendingContention[wklSelectedId]++; } - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) { spurs->wklPendingContention[i] = pendingContention[i]; ctxt->wklLocPendingContention[i] = 0; @@ -409,7 +409,7 @@ bool spursKernel1SelectWorkload(spu_thread& spu) else { // Not called by kernel and no context switch is required - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) { spurs->wklPendingContention[i] = spurs->wklPendingContention[i] - ctxt->wklLocPendingContention[i]; ctxt->wklLocPendingContention[i] = 0; @@ -446,17 +446,17 @@ bool spursKernel2SelectWorkload(spu_thread& spu) // Calculate the contention (number of SPUs used) for each workload u8 contention[CELL_SPURS_MAX_WORKLOAD2]; u8 pendingContention[CELL_SPURS_MAX_WORKLOAD2]; - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD2; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD2; i++) { contention[i] = spurs->wklCurrentContention[i & 0x0F] - ctxt->wklLocContention[i & 0x0F]; - contention[i] = i < CELL_SPURS_MAX_WORKLOAD ? contention[i] & 0x0F : contention[i] >> 4; + contention[i] = i + 0u < CELL_SPURS_MAX_WORKLOAD ? contention[i] & 0x0F : contention[i] >> 4; // If this is a poll request then the number of SPUs pending to context switch is also added to the contention presumably // to prevent unnecessary jumps to the kernel if (isPoll) { pendingContention[i] = spurs->wklPendingContention[i & 0x0F] - ctxt->wklLocPendingContention[i & 0x0F]; - pendingContention[i] = i < CELL_SPURS_MAX_WORKLOAD ? pendingContention[i] & 0x0F : pendingContention[i] >> 4; + pendingContention[i] = i + 0u < CELL_SPURS_MAX_WORKLOAD ? pendingContention[i] & 0x0F : pendingContention[i] >> 4; if (i != ctxt->wklCurrentId) { contention[i] += pendingContention[i]; @@ -483,9 +483,9 @@ bool spursKernel2SelectWorkload(spu_thread& spu) { // Caclulate the scheduling weight for each workload u8 maxWeight = 0; - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD2; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD2; i++) { - auto j = i & 0x0F; + u32 j = i & 0x0f; u16 runnable = i < CELL_SPURS_MAX_WORKLOAD ? ctxt->wklRunnable1 & (0x8000 >> j) : ctxt->wklRunnable2 & (0x8000 >> j); u8 priority = i < CELL_SPURS_MAX_WORKLOAD ? ctxt->priority[j] & 0x0F : ctxt->priority[j] >> 4; u8 maxContention = i < CELL_SPURS_MAX_WORKLOAD ? spurs->wklMaxContention[j] & 0x0F : spurs->wklMaxContention[j] >> 4; @@ -551,7 +551,7 @@ bool spursKernel2SelectWorkload(spu_thread& spu) contention[wklSelectedId]++; } - for (auto i = 0; i < (CELL_SPURS_MAX_WORKLOAD2 >> 1); i++) + for (u32 i = 0; i < (CELL_SPURS_MAX_WORKLOAD2 >> 1); i++) { spurs->wklCurrentContention[i] = contention[i] | (contention[i + 0x10] << 4); spurs->wklPendingContention[i] = spurs->wklPendingContention[i] - ctxt->wklLocPendingContention[i]; @@ -571,7 +571,7 @@ bool spursKernel2SelectWorkload(spu_thread& spu) pendingContention[wklSelectedId]++; } - for (auto i = 0; i < (CELL_SPURS_MAX_WORKLOAD2 >> 1); i++) + for (u32 i = 0; i < (CELL_SPURS_MAX_WORKLOAD2 >> 1); i++) { spurs->wklPendingContention[i] = pendingContention[i] | (pendingContention[i + 0x10] << 4); ctxt->wklLocPendingContention[i] = 0; @@ -582,7 +582,7 @@ bool spursKernel2SelectWorkload(spu_thread& spu) else { // Not called by kernel and no context switch is required - for (auto i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) + for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) { spurs->wklPendingContention[i] = spurs->wklPendingContention[i] - ctxt->wklLocPendingContention[i]; ctxt->wklLocPendingContention[i] = 0; diff --git a/rpcs3/Emu/Cell/Modules/cellSsl.cpp b/rpcs3/Emu/Cell/Modules/cellSsl.cpp index 007c7e9555..e5e04a281d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSsl.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSsl.cpp @@ -112,7 +112,7 @@ error_code cellSslCertificateLoader(u64 flag, vm::ptr buffer, u32 size, vm if (required) { *required = 0; - for (int i = 1; i <= flagBits.size(); i++) + for (uint i = 1; i <= flagBits.size(); i++) { if (!flagBits[i-1]) continue; @@ -123,7 +123,7 @@ error_code cellSslCertificateLoader(u64 flag, vm::ptr buffer, u32 size, vm else { std::string final; - for (int i = 1; i <= flagBits.size(); i++) + for (uint i = 1; i <= flagBits.size(); i++) { if (!flagBits[i-1]) continue; diff --git a/rpcs3/Emu/Cell/Modules/cellSync.cpp b/rpcs3/Emu/Cell/Modules/cellSync.cpp index 8bb4fc5714..751fe25b8c 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSync.cpp @@ -1087,7 +1087,7 @@ error_code _cellSyncLFQueueCompletePushPointer(ppu_thread& ppu, vm::ptrpush2.compare_and_swap_test(old, push2)) { verify(HERE), (var2 + var4 < 16); - if (var6 != -1) + if (var6 != umax) { verify(HERE), (queue->push3.compare_and_swap_test(old2, push3)); verify(HERE), (fpSendSignal); @@ -1146,7 +1146,7 @@ error_code _cellSyncLFQueuePushBody(ppu_thread& ppu, vm::ptr qu res = _cellSyncLFQueueGetPushPointer2(ppu, queue, position, isBlocking, 0); } - if (!isBlocking || res != CELL_SYNC_ERROR_AGAIN) + if (!isBlocking || res + 0u != CELL_SYNC_ERROR_AGAIN) { if (res) return not_an_error(res); @@ -1386,7 +1386,7 @@ error_code _cellSyncLFQueueCompletePopPointer(ppu_thread& ppu, vm::ptrpop2.compare_and_swap_test(old, pop2)) { - if (var6 != -1) + if (var6 != umax) { verify(HERE), (queue->pop3.compare_and_swap_test(old2, pop3)); verify(HERE), (fpSendSignal); @@ -1445,7 +1445,7 @@ error_code _cellSyncLFQueuePopBody(ppu_thread& ppu, vm::ptr que res = _cellSyncLFQueueGetPopPointer2(ppu, queue, position, isBlocking, 0); } - if (!isBlocking || res != CELL_SYNC_ERROR_AGAIN) + if (!isBlocking || res + 0u != CELL_SYNC_ERROR_AGAIN) { if (res) return not_an_error(res); diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index d95b5a83d1..8b2617d2d9 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -227,15 +227,15 @@ struct vdec_context final packet.data = vm::_ptr(au_addr); packet.size = au_size; - packet.pts = au_pts != -1 ? au_pts : INT64_MIN; - packet.dts = au_dts != -1 ? au_dts : INT64_MIN; + packet.pts = au_pts != umax ? au_pts : INT64_MIN; + packet.dts = au_dts != umax ? au_dts : INT64_MIN; - if (next_pts == 0 && au_pts != -1) + if (next_pts == 0 && au_pts != umax) { next_pts = au_pts; } - if (next_dts == 0 && au_dts != -1) + if (next_dts == 0 && au_dts != umax) { next_dts = au_dts; } @@ -528,7 +528,7 @@ static error_code vdecQueryAttr(s32 type, u32 profile, u32 spec_addr /* may be 0 { return CELL_VDEC_ERROR_ARG; } - + memSize = new_sdk ? 0xD2F40B : 0xEB990B; break; } diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index 5a2fa772eb..eb7b9fee89 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -280,8 +280,8 @@ error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, switch (videoOut) { case CELL_VIDEO_OUT_PRIMARY: return not_an_error( - resolutionId == g_video_out_resolution_id.at(g_cfg.video.resolution) - && (aspect == CELL_VIDEO_OUT_ASPECT_AUTO || aspect == g_video_out_aspect_id.at(g_cfg.video.aspect_ratio)) + resolutionId == g_video_out_resolution_id.at(g_cfg.video.resolution) + 0u + && (aspect == CELL_VIDEO_OUT_ASPECT_AUTO || aspect == g_video_out_aspect_id.at(g_cfg.video.aspect_ratio) + 0u) ); case CELL_VIDEO_OUT_SECONDARY: return not_an_error(0); } diff --git a/rpcs3/Emu/Cell/Modules/libmixer.cpp b/rpcs3/Emu/Cell/Modules/libmixer.cpp index 7a34d0ddda..a72e87208e 100644 --- a/rpcs3/Emu/Cell/Modules/libmixer.cpp +++ b/rpcs3/Emu/Cell/Modules/libmixer.cpp @@ -412,7 +412,7 @@ struct surmixer_thread : ppu_thread g_surmx.mixdata[i * 8 + 1] += right; } if ((p.m_position == p.m_samples && p.m_speed > 0.0f) || - (p.m_position == ~0 && p.m_speed < 0.0f)) // loop or stop + (p.m_position = umax && p.m_speed < 0.0f)) // loop or stop { if (p.m_loop_mode == CELL_SSPLAYER_LOOP_ON) { diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 7b93ce29d0..5bcc7ddf04 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -91,7 +91,7 @@ struct sce_np_trophy_manager { error = SCE_NP_TROPHY_ERROR_ABORT; return res; - } + } return res; } @@ -231,7 +231,7 @@ error_code sceNpTrophyTerm() ids[it++] = id; }; - // This functionality could be implemented in idm instead + // This functionality could be implemented in idm instead idm::select(get_handles); while (it) @@ -662,7 +662,7 @@ error_code sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, vm::ptr { sceNpTrophy.warning("sceNpTrophyGetRequiredDiskSpace(): Trophy config is already installed (trp_name=%s)", ctxt->trp_name); } - + sceNpTrophy.warning("sceNpTrophyGetRequiredDiskSpace(): reqspace is 0x%llx", space); *reqspace = space; @@ -861,7 +861,7 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt const std::string& config_path = vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name + "/TROPCONF.SFM"); const u32 unlocked_platinum_id = ctxt->tropusr->GetUnlockedPlatinumID(trophyId, config_path); - if (unlocked_platinum_id != SCE_NP_TROPHY_INVALID_TROPHY_ID) + if (unlocked_platinum_id != 0u + SCE_NP_TROPHY_INVALID_TROPHY_ID) { sceNpTrophy.warning("sceNpTrophyUnlockTrophy: All requirements for unlocking the platinum trophy (ID = %d) were met.)", unlocked_platinum_id); @@ -885,7 +885,7 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt // Enqueue popup for the regular trophy show_trophy_notification(ctxt, trophyId); - if (unlocked_platinum_id != SCE_NP_TROPHY_INVALID_TROPHY_ID) + if (unlocked_platinum_id != 0u + SCE_NP_TROPHY_INVALID_TROPHY_ID) { // Enqueue popup for the holy platinum trophy show_trophy_notification(ctxt, unlocked_platinum_id); diff --git a/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp b/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp index 95813eadca..cdbee41d64 100644 --- a/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp @@ -77,7 +77,7 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr lwcond) lwmutex->all_info--; - if (res != CELL_EPERM) + if (res + 0u != CELL_EPERM) { return res; } @@ -90,7 +90,7 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr lwcond) { // if locking failed - if (res != CELL_EBUSY) + if (res + 0u != CELL_EBUSY) { return CELL_ESRCH; } @@ -115,7 +115,7 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr lwcond) // unlock the lightweight mutex sys_lwmutex_unlock(ppu, lwmutex); - if (res != CELL_ENOENT) + if (res + 0u != CELL_ENOENT) { return res; } @@ -164,7 +164,7 @@ error_code sys_lwcond_signal_all(ppu_thread& ppu, vm::ptr lwcond) { // if locking failed - if (res != CELL_EBUSY) + if (res + 0u != CELL_EBUSY) { return CELL_ESRCH; } @@ -235,7 +235,7 @@ error_code sys_lwcond_signal_to(ppu_thread& ppu, vm::ptr lwcond, u { // if locking failed - if (res != CELL_EBUSY) + if (res + 0u != CELL_EBUSY) { return CELL_ESRCH; } @@ -300,7 +300,7 @@ error_code sys_lwcond_wait(ppu_thread& ppu, vm::ptr lwcond, u64 ti return 0; } - if (res == CELL_OK || res == CELL_ESRCH) + if (res == CELL_OK || res + 0u == CELL_ESRCH) { if (res == CELL_OK) { @@ -319,7 +319,7 @@ error_code sys_lwcond_wait(ppu_thread& ppu, vm::ptr lwcond, u64 ti return res; } - if (res == CELL_EBUSY || res == CELL_ETIMEDOUT) + if (res + 0u == CELL_EBUSY || res + 0u == CELL_ETIMEDOUT) { if (error_code res2 = sys_lwmutex_lock(ppu, lwmutex, 0)) { @@ -329,7 +329,7 @@ error_code sys_lwcond_wait(ppu_thread& ppu, vm::ptr lwcond, u64 ti // if successfully locked, restore recursive value lwmutex->recursive_count = recursive_value; - if (res == CELL_EBUSY) + if (res + 0u == CELL_EBUSY) { return CELL_OK; } @@ -337,7 +337,7 @@ error_code sys_lwcond_wait(ppu_thread& ppu, vm::ptr lwcond, u64 ti return res; } - if (res == CELL_EDEADLK) + if (res + 0u == CELL_EDEADLK) { // restore owner and recursive value const auto old = lwmutex->vars.owner.exchange(tid); diff --git a/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp b/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp index 914b421862..830485f99a 100644 --- a/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp @@ -186,7 +186,7 @@ error_code sys_lwmutex_lock(ppu_thread& ppu, vm::ptr lwmutex, u64 return CELL_OK; } - if (res == CELL_EBUSY && lwmutex->attribute & SYS_SYNC_RETRY) + if (res + 0u == CELL_EBUSY && lwmutex->attribute & SYS_SYNC_RETRY) { while (true) { @@ -224,7 +224,7 @@ error_code sys_lwmutex_lock(ppu_thread& ppu, vm::ptr lwmutex, u64 { lwmutex->vars.owner.release(tid); } - else if (timeout && res_ != CELL_ETIMEDOUT) + else if (timeout && res_ + 0u != CELL_ETIMEDOUT) { const u64 time_diff = get_guest_system_time() - time0; @@ -239,7 +239,7 @@ error_code sys_lwmutex_lock(ppu_thread& ppu, vm::ptr lwmutex, u64 lwmutex->all_info--; - if (res_ != CELL_EBUSY) + if (res_ + 0u != CELL_EBUSY) { return res_; } @@ -358,7 +358,7 @@ error_code sys_lwmutex_unlock(ppu_thread& ppu, vm::ptr lwmutex) lwmutex->vars.owner.release(lwmutex_free); // Call the alternative syscall - if (_sys_lwmutex_unlock2(ppu, lwmutex->sleep_queue) == CELL_ESRCH) + if (_sys_lwmutex_unlock2(ppu, lwmutex->sleep_queue) + 0u == CELL_ESRCH) { return CELL_ESRCH; } @@ -370,7 +370,7 @@ error_code sys_lwmutex_unlock(ppu_thread& ppu, vm::ptr lwmutex) lwmutex->vars.owner.release(lwmutex_reserved); // call the syscall - if (_sys_lwmutex_unlock(ppu, lwmutex->sleep_queue) == CELL_ESRCH) + if (_sys_lwmutex_unlock(ppu, lwmutex->sleep_queue) + 0u == CELL_ESRCH) { return CELL_ESRCH; } diff --git a/rpcs3/Emu/Cell/Modules/sys_mempool.cpp b/rpcs3/Emu/Cell/Modules/sys_mempool.cpp index 49c82d1a45..bddad6fe72 100644 --- a/rpcs3/Emu/Cell/Modules/sys_mempool.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_mempool.cpp @@ -69,7 +69,7 @@ s32 sys_mempool_create(ppu_thread& ppu, vm::ptr mempool, vm::ptr< // TODO: check blocks alignment wrt ralignment u64 num_blocks = chunk_size / block_size; memory_pool->free_blocks.resize(num_blocks); - for (int i = 0; i < num_blocks; ++i) + for (u32 i = 0; i < num_blocks; ++i) { memory_pool->free_blocks[i] = vm::ptr::make(chunk.addr() + i * block_size); } diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 8737d43603..c6424ba131 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -64,7 +64,7 @@ void ppu_module::validate(u32 reloc) const u32 addr = func["addr"].as(-1); const u32 size = func["size"].as(0); - if (addr != -1 && index < funcs.size()) + if (addr != umax && index < funcs.size()) { u32 found = funcs[index].addr - reloc; @@ -567,7 +567,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) if (func.addr) { - if (toc && func.toc && func.toc != -1 && func.toc != toc) + if (toc && func.toc && func.toc != umax && func.toc != toc) { func.toc = -1; } @@ -592,7 +592,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) // Register new TOC and find basic set of functions auto add_toc = [&](u32 toc) { - if (!toc || toc == -1 || !TOCs.emplace(toc).second) + if (!toc || toc == umax || !TOCs.emplace(toc).second) { return; } @@ -719,7 +719,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) // Clean TOCs for (auto&& pair : fmap) { - if (pair.second.toc == -1) + if (pair.second.toc == umax) { pair.second.toc = 0; } @@ -842,7 +842,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) ppu_function& func = func_queue[i]; // Fixup TOCs - if (func.toc && func.toc != -1) + if (func.toc && func.toc != umax) { for (u32 addr : func.callers) { @@ -989,13 +989,13 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) { auto& new_func = add_func(target, 0, func.addr); - if (func.toc && func.toc != -1 && new_func.toc == 0) + if (func.toc && func.toc != umax && new_func.toc == 0) { const u32 toc = func.toc + toc_add; add_toc(toc); add_func(new_func.addr, toc, 0); } - else if (new_func.toc && new_func.toc != -1 && func.toc == 0) + else if (new_func.toc && new_func.toc != umax && func.toc == 0) { const u32 toc = new_func.toc - toc_add; add_toc(toc); @@ -1036,13 +1036,13 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) { auto& new_func = add_func(target, 0, func.addr); - if (func.toc && func.toc != -1 && new_func.toc == 0) + if (func.toc && func.toc != umax && new_func.toc == 0) { const u32 toc = func.toc + toc_add; add_toc(toc); add_func(new_func.addr, toc, 0); } - else if (new_func.toc && new_func.toc != -1 && func.toc == 0) + else if (new_func.toc && new_func.toc != umax && func.toc == 0) { const u32 toc = new_func.toc - toc_add; add_toc(toc); @@ -2262,7 +2262,7 @@ void ppu_acontext::RLWIMI(ppu_opcode_t op) max = utils::rol64(static_cast(max) | max << 32, op.sh32) & mask; } - if (mask != -1) + if (mask != umax) { // Insertion min |= gpr[op.ra].bmin & ~mask; @@ -2484,7 +2484,7 @@ void ppu_acontext::RLDIMI(ppu_opcode_t op) min = utils::rol64(min, sh) & mask; max = utils::rol64(max, sh) & mask; - if (mask != -1) + if (mask != umax) { // Insertion min |= gpr[op.ra].bmin & ~mask; diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index 467c391c17..3877f3a690 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -1029,7 +1029,7 @@ struct ppu_acontext const u64 bdiv = rhs.div(); // Check overflow, generate normalized range - if (adiv != -1 && bdiv != -1 && adiv <= adiv + bdiv) + if (adiv != umax && bdiv != umax && adiv <= adiv + bdiv) { r = range(imin + rhs.imin, imax + rhs.imax); } diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index 102171e23e..0a0ca1af66 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -4251,7 +4251,7 @@ bool ppu_interpreter::SRAW(ppu_thread& ppu, ppu_opcode_t op) else { ppu.gpr[op.ra] = RS >> shift; - ppu.xer.ca = (RS < 0) && ((ppu.gpr[op.ra] << shift) != RS); + ppu.xer.ca = (RS < 0) && ((ppu.gpr[op.ra] << shift) != static_cast(RS)); } if (op.rc) [[unlikely]] ppu_cr_set(ppu, 0, ppu.gpr[op.ra], 0); @@ -4270,7 +4270,7 @@ bool ppu_interpreter::SRAD(ppu_thread& ppu, ppu_opcode_t op) else { ppu.gpr[op.ra] = RS >> shift; - ppu.xer.ca = (RS < 0) && ((ppu.gpr[op.ra] << shift) != RS); + ppu.xer.ca = (RS < 0) && ((ppu.gpr[op.ra] << shift) != static_cast(RS)); } if (op.rc) [[unlikely]] ppu_cr_set(ppu, 0, ppu.gpr[op.ra], 0); @@ -4296,7 +4296,7 @@ bool ppu_interpreter::SRAWI(ppu_thread& ppu, ppu_opcode_t op) { s32 RS = static_cast(ppu.gpr[op.rs]); ppu.gpr[op.ra] = RS >> op.sh32; - ppu.xer.ca = (RS < 0) && (static_cast(ppu.gpr[op.ra] << op.sh32) != RS); + ppu.xer.ca = (RS < 0) && (static_cast(ppu.gpr[op.ra] << op.sh32) != static_cast(RS)); if (op.rc) [[unlikely]] ppu_cr_set(ppu, 0, ppu.gpr[op.ra], 0); return true; @@ -4307,7 +4307,7 @@ bool ppu_interpreter::SRADI(ppu_thread& ppu, ppu_opcode_t op) auto sh = op.sh64; s64 RS = ppu.gpr[op.rs]; ppu.gpr[op.ra] = RS >> sh; - ppu.xer.ca = (RS < 0) && ((ppu.gpr[op.ra] << sh) != RS); + ppu.xer.ca = (RS < 0) && ((ppu.gpr[op.ra] << sh) != static_cast(RS)); if (op.rc) [[unlikely]] ppu_cr_set(ppu, 0, ppu.gpr[op.ra], 0); return true; diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 325f366085..86b2d49808 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -800,7 +800,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, const std::stri if (s.sh_type == 1u && addr && size) // TODO: some sections with addr=0 are valid { - for (auto i = 0; i < prx->segs.size(); i++) + for (std::size_t i = 0; i < prx->segs.size(); i++) { const u32 saddr = static_cast(elf.progs[i].p_vaddr); if (addr >= saddr && addr < saddr + elf.progs[i].p_memsz) @@ -1742,7 +1742,7 @@ std::shared_ptr ppu_load_overlay(const ppu_exec_object& elf, const ppu_loader.warning("Bad process_param size! [0x%x : 0x%x]", info.size, u32{sizeof(process_param_t)}); } - if (info.magic != "OVLM"_u32) //string "OVLM" + if (info.magic != 0x4f564c4du) //string "OVLM" { ppu_loader.error("Bad process_param magic! [0x%x]", info.magic); } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 52d46815ba..c757a8d0f6 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1338,7 +1338,7 @@ extern void ppu_initialize(const ppu_module& info) ppu_register_function_at(block.first, block.second, nullptr); } - if (g_cfg.core.ppu_debug && func.size && func.toc != -1) + if (g_cfg.core.ppu_debug && func.size && func.toc != umax) { s_ppu_toc->emplace(func.addr, func.toc); ppu_ref(func.addr) = ::narrow(reinterpret_cast(&ppu_check_toc)); diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 29c3cb2d65..aef2c43edf 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -260,7 +260,7 @@ void PPUTranslator::CallFunction(u64 target, Value* indirect) if (!indirect) { - if ((!m_reloc && target < 0x10000) || target >= -0x10000) + if ((!m_reloc && target < 0x10000) || target >= u64{} - 0x10000) { Trap(); return; @@ -1943,7 +1943,7 @@ void PPUTranslator::RLWIMI(ppu_opcode_t op) result = m_ir->CreateAnd(RotateLeft(DuplicateExt(GetGpr(op.rs, 32)), op.sh32), mask); } - if (mask != -1) + if (mask != umax) { // Insertion result = m_ir->CreateOr(result, m_ir->CreateAnd(GetGpr(op.ra), ~mask)); @@ -2193,7 +2193,7 @@ void PPUTranslator::RLDIMI(ppu_opcode_t op) result = m_ir->CreateAnd(RotateLeft(GetGpr(op.rs), sh), mask); } - if (mask != -1) + if (mask != umax) { // Insertion result = m_ir->CreateOr(result, m_ir->CreateAnd(GetGpr(op.ra), ~mask)); @@ -2303,7 +2303,7 @@ void PPUTranslator::MFOCRF(ppu_opcode_t op) const u64 pos = countLeadingZeros(op.crm, ZB_Width) - 24; - if (pos >= 8 || 0x80 >> pos != op.crm) + if (pos >= 8 || 0x80u >> pos != op.crm) { CompilationError("MFOCRF: Undefined behaviour"); SetGpr(op.rd, UndefValue::get(GetType())); @@ -2565,7 +2565,7 @@ void PPUTranslator::MTOCRF(ppu_opcode_t op) // MTOCRF const u64 pos = countLeadingZeros(op.crm, ZB_Width) - 24; - if (pos >= 8 || 128 >> pos != op.crm) + if (pos >= 8 || 0x80u >> pos != op.crm) { CompilationError("MTOCRF: Undefined behaviour"); return; diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index c9cc92126f..856ec2ad65 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -304,7 +304,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func) continue; } - const bool first = ls_off == -8192; + const bool first = ls_off == u32{} - 8192; // Ensure small distance for disp8*N if (j - ls_off >= 8192) @@ -429,7 +429,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func) continue; } - const bool first = ls_off == -4096; + const bool first = ls_off == u32{0} - 4096; // Ensure small distance for disp8*N if (j - ls_off >= 4096) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 8464671f6e..5f5a29c0b4 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -80,7 +80,7 @@ static FORCE_INLINE rsx::thread* get_rsx_if_needs_res_pause(u32 addr) ASSUME(render); - if (render->iomap_table.io[addr >> 20] == -1) [[likely]] + if (render->iomap_table.io[addr >> 20].load() == umax) [[likely]] { return {}; } diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index fbf2b64331..0849c3eaa2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -30,7 +30,7 @@ bool lv2_event_queue::send(lv2_event event) if (sq.empty()) { - if (events.size() < this->size) + if (events.size() < this->size + 0u) { // Save event events.emplace_back(event); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index ee7ef59830..a02f5d1bfd 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -258,7 +258,7 @@ error_code sys_fs_open(ppu_thread& ppu, vm::cptr path, s32 flags, vm::ptr< const auto mp = lv2_fs_object::get_mp(vpath); - if (vpath.find_first_not_of('/') == -1) + if (vpath.find_first_not_of('/') == umax) { return {CELL_EISDIR, path}; } @@ -764,7 +764,7 @@ error_code sys_fs_stat(ppu_thread& ppu, vm::cptr path, vm::ptr const auto mp = lv2_fs_object::get_mp(vpath); - if (vpath.find_first_not_of('/') == -1) + if (vpath.find_first_not_of('/') == umax) { *sb = {CELL_FS_S_IFDIR | 0444}; return CELL_OK; @@ -898,7 +898,7 @@ error_code sys_fs_mkdir(ppu_thread& ppu, vm::cptr path, s32 mode) const std::string_view vpath = path.get_ptr(); const std::string local_path = vfs::get(vpath); - if (vpath.find_first_not_of('/') == -1) + if (vpath.find_first_not_of('/') == umax) { return {CELL_EEXIST, path}; } @@ -945,7 +945,7 @@ error_code sys_fs_rename(ppu_thread& ppu, vm::cptr from, vm::cptr to const std::string_view vto = to.get_ptr(); const std::string local_to = vfs::get(vto); - if (vfrom.find_first_not_of('/') == -1 || vto.find_first_not_of('/') == -1) + if (vfrom.find_first_not_of('/') == umax || vto.find_first_not_of('/') == umax) { return CELL_EPERM; } @@ -1000,7 +1000,7 @@ error_code sys_fs_rmdir(ppu_thread& ppu, vm::cptr path) const std::string_view vpath = path.get_ptr(); const std::string local_path = vfs::get(vpath); - if (vpath.find_first_not_of('/') == -1) + if (vpath.find_first_not_of('/') == umax) { return {CELL_EPERM, path}; } @@ -1052,7 +1052,7 @@ error_code sys_fs_unlink(ppu_thread& ppu, vm::cptr path) const std::size_t dev_start = vpath.find_first_not_of('/'); - if (dev_start == -1) + if (dev_start == umax) { return {CELL_EISDIR, path}; } @@ -1540,7 +1540,7 @@ error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr const u64 result = file->file.seek(offset, static_cast(whence)); - if (result == -1) + if (result == umax) { switch (auto error = fs::g_tls_error) { @@ -1624,7 +1624,7 @@ error_code sys_fs_get_block_size(ppu_thread& ppu, vm::cptr path, vm::ptr path, u64 size) const std::string_view vpath = path.get_ptr(); const std::string local_path = vfs::get(vpath); - if (vpath.find_first_not_of('/') == -1) + if (vpath.find_first_not_of('/') == umax) { return {CELL_EISDIR, path}; } @@ -1858,7 +1858,7 @@ error_code sys_fs_utime(ppu_thread& ppu, vm::cptr path, vm::cptr(lwcond_id, [&](lv2_lwcond& cond) -> int { - if (ppu_thread_id != -1 && !idm::check_unlocked>(ppu_thread_id)) + if (ppu_thread_id != umax && !idm::check_unlocked>(ppu_thread_id)) { return -1; } @@ -110,7 +110,7 @@ error_code _sys_lwcond_signal(ppu_thread& ppu, u32 lwcond_id, u32 lwmutex_id, u3 cpu_thread* result = nullptr; - if (ppu_thread_id != -1) + if (ppu_thread_id != umax) { for (auto cpu : cond.sq) { @@ -161,7 +161,7 @@ error_code _sys_lwcond_signal(ppu_thread& ppu, u32 lwcond_id, u32 lwmutex_id, u3 if (!cond.ret) { - if (ppu_thread_id == -1) + if (ppu_thread_id == umax) { if (mode == 3) { diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index 1fe2465e5d..21266fff62 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -708,8 +708,9 @@ error_code sys_mmapper_enable_page_fault_notification(ppu_thread& ppu, u32 start error_code res = sys_event_port_create(port_id, SYS_EVENT_PORT_LOCAL, SYS_MEMORY_PAGE_FAULT_EVENT_KEY); sys_event_port_connect_local(*port_id, event_queue_id); - if (res == CELL_EAGAIN) - { // Not enough system resources. + if (res + 0u == CELL_EAGAIN) + { + // Not enough system resources. return CELL_EAGAIN; } diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index ef167696ed..c23cde426b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -443,7 +443,7 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr return -sys_net_error{result}; } - if (ppu.gpr[3] == -SYS_NET_EINTR) + if (ppu.gpr[3] == static_cast(-SYS_NET_EINTR)) { return -SYS_NET_EINTR; } @@ -679,7 +679,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr(-SYS_NET_EINTR)) { return -SYS_NET_EINTR; } @@ -1113,7 +1113,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr buf, u32 return -result; } - if (ppu.gpr[3] == -SYS_NET_EINTR) + if (ppu.gpr[3] == static_cast(-SYS_NET_EINTR)) { return -SYS_NET_EINTR; } @@ -1283,7 +1283,7 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr buf, u32 l return -result; } - if (ppu.gpr[3] == -SYS_NET_EINTR) + if (ppu.gpr[3] == static_cast(-SYS_NET_EINTR)) { return -SYS_NET_EINTR; } diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 9e37efe74c..ae50cb8f97 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -30,7 +30,7 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode) // Joinable, not joined value = -3; } - else if (value != -1) + else if (value != umax) { // Joinable, joined value = -2; @@ -39,7 +39,7 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode) // Detached otherwise }); - if (jid == -1) + if (jid == umax) { // Detach detached thread, id will be removed on cleanup static_cast&>(ppu) = thread_state::detached; @@ -76,13 +76,13 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr vptr { CellError result = thread.joiner.atomic_op([&](u32& value) -> CellError { - if (value == -3) + if (value == 0u - 3) { value = -2; return CELL_EBUSY; } - if (value == -2) + if (value == 0u - 2) { return CELL_ESRCH; } @@ -149,18 +149,18 @@ error_code sys_ppu_thread_detach(u32 thread_id) { return thread.joiner.atomic_op([&](u32& value) -> CellError { - if (value == -3) + if (value == 0u - 3) { value = -2; return CELL_EAGAIN; } - if (value == -2) + if (value == 0u - 2) { return CELL_ESRCH; } - if (value == -1) + if (value == umax) { return CELL_EINVAL; } @@ -202,7 +202,7 @@ error_code sys_ppu_thread_get_join_state(ppu_thread& ppu, vm::ptr isjoinabl return CELL_EFAULT; } - *isjoinable = ppu.joiner != -1; + *isjoinable = ppu.joiner != umax; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_ss.cpp b/rpcs3/Emu/Cell/lv2/sys_ss.cpp index 35e3471dca..57641d4b28 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ss.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ss.cpp @@ -69,7 +69,7 @@ error_code sys_ss_access_control_engine(u64 pkg_id, u64 a2, u64 a3) { sys_ss.todo("sys_ss_access_control_engine(pkg_id=0x%llx, a2=0x%llx, a3=0x%llx)", pkg_id, a2, a3); - const u64 authid = g_ps3_process_info.self_info.valid ? + const u64 authid = g_ps3_process_info.self_info.valid ? g_ps3_process_info.self_info.app_info.authid : 0; switch (pkg_id) @@ -86,7 +86,7 @@ error_code sys_ss_access_control_engine(u64 pkg_id, u64 a2, u64 a3) return CELL_ESRCH; } - verify(HERE), a2 == process_getpid(); + verify(HERE), a2 == static_cast(process_getpid()); vm::write64(vm::cast(a3), authid); break; } diff --git a/rpcs3/Emu/GDB.cpp b/rpcs3/Emu/GDB.cpp index 10f0eb85ab..11d24b014c 100644 --- a/rpcs3/Emu/GDB.cpp +++ b/rpcs3/Emu/GDB.cpp @@ -358,7 +358,8 @@ void gdb_thread::send_cmd(const std::string& cmd) std::string buf; buf.reserve(cmd.length() + 4); buf += "$"; - for (int i = 0; i < cmd.length(); ++i) { + for (std::size_t i = 0; i < cmd.length(); ++i) + { checksum = (checksum + append_encoded_char(cmd[i], buf)) % 256; } buf += "#"; diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp index a6fd9fdfef..66bd90dc66 100644 --- a/rpcs3/Emu/Io/PadHandler.cpp +++ b/rpcs3/Emu/Io/PadHandler.cpp @@ -300,7 +300,7 @@ void PadHandlerBase::init_configs() { int index = 0; - for (int i = 0; i < MAX_GAMEPADS; i++) + for (u32 i = 0; i < MAX_GAMEPADS; i++) { if (g_cfg_input.player[i]->handler == m_type) { diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index add27bf07f..09610ac50d 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -546,7 +546,7 @@ public: if (I == m_fragment_shader_cache.end()) return; - verify(HERE), (dst_buffer.size_bytes() >= ::narrow(I->second.FragmentConstantOffsetCache.size()) * 16); + verify(HERE), (dst_buffer.size_bytes() >= ::narrow(I->second.FragmentConstantOffsetCache.size()) * 16u); f32* dst = dst_buffer.data(); alignas(16) f32 tmp[4]; diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Common/ShaderParam.h index 22880f81a8..7711913db0 100644 --- a/rpcs3/Emu/RSX/Common/ShaderParam.h +++ b/rpcs3/Emu/RSX/Common/ShaderParam.h @@ -226,7 +226,7 @@ public: { std::unordered_map swizzle; - static std::unordered_map pos_to_swizzle = + static std::unordered_map pos_to_swizzle = { { 0, 'x' }, { 1, 'y' }, @@ -234,18 +234,18 @@ public: { 3, 'w' } }; - for (auto &i : pos_to_swizzle) + for (auto& p : pos_to_swizzle) { - swizzle[i.second] = swizzles[0].length() > i.first ? swizzles[0][i.first] : 0; + swizzle[p.second] = swizzles[0].length() > p.first ? swizzles[0][p.first] : 0; } - for (int i = 1; i < swizzles.size(); ++i) + for (uint i = 1; i < swizzles.size(); ++i) { std::unordered_map new_swizzle; - for (auto &sw : pos_to_swizzle) + for (auto& p : pos_to_swizzle) { - new_swizzle[sw.second] = swizzle[swizzles[i].length() <= sw.first ? '\0' : swizzles[i][sw.first]]; + new_swizzle[p.second] = swizzle[swizzles[i].length() <= p.first ? '\0' : swizzles[i][p.first]]; } swizzle = new_swizzle; @@ -254,10 +254,10 @@ public: swizzles.clear(); std::string new_swizzle; - for (auto &i : pos_to_swizzle) + for (auto& p : pos_to_swizzle) { - if (swizzle[i.second] != '\0') - new_swizzle += swizzle[i.second]; + if (swizzle[p.second] != '\0') + new_swizzle += swizzle[p.second]; } swizzles.push_back(new_swizzle); diff --git a/rpcs3/Emu/RSX/Common/surface_utils.h b/rpcs3/Emu/RSX/Common/surface_utils.h index ff01a9b8c7..3a174e4105 100644 --- a/rpcs3/Emu/RSX/Common/surface_utils.h +++ b/rpcs3/Emu/RSX/Common/surface_utils.h @@ -367,7 +367,7 @@ namespace rsx {0, size_y}, }; - for (int n = 0; n < memory_tag_samples.size(); ++n) + for (uint n = 0; n < memory_tag_samples.size(); ++n) { const auto sample_offset = (samples[n].y * rsx_pitch) + samples[n].x; memory_tag_samples[n].first = (sample_offset + base_addr); diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index 1552c120c8..b58c0f04b7 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -106,7 +106,7 @@ void GLFragmentDecompilerThread::insertOutputs(std::stringstream & OS) const bool float_type = (m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) || !device_props.has_native_half_support; const auto reg_type = float_type ? "vec4" : getHalfTypeName(4); - for (int i = 0; i < std::size(table); ++i) + for (uint i = 0; i < std::size(table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, reg_type, table[i].second)) OS << "layout(location=" << i << ") out vec4 " << table[i].first << ";\n"; diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index 4ce8aa9cba..4c1bfd1858 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -2206,7 +2206,7 @@ public: { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_last_binding); - if (m_last_binding != new_binding.id()) + if (m_last_binding + 0u != new_binding.id()) new_binding.bind(); else reset = false; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp index 75e6e3abbd..b4220d2599 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp @@ -297,7 +297,7 @@ namespace rsx else progress_2.inc(value); - if (index == taskbar_index || taskbar_index == -1) + if (index == static_cast(taskbar_index) || taskbar_index == -1) Emu.GetCallbacks().handle_taskbar_progress(1, static_cast(value)); return CELL_OK; @@ -328,7 +328,7 @@ namespace rsx else progress_2.set_limit(static_cast(limit)); - if (index == taskbar_index) + if (index == static_cast(taskbar_index)) { taskbar_limit = limit; Emu.GetCallbacks().handle_taskbar_progress(2, taskbar_limit); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index 2f4979c21f..59054c05fe 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -251,7 +251,7 @@ namespace rsx if (auto err = run_input_loop()) return err; - if (return_code == entries.size() && !newpos_head) + if (return_code + 0u == entries.size() && !newpos_head) return selection_code::new_save; if (return_code >= 0 && newpos_head) return return_code - 1; diff --git a/rpcs3/Emu/RSX/RSXFIFO.cpp b/rpcs3/Emu/RSX/RSXFIFO.cpp index ff215887c3..46cf34669b 100644 --- a/rpcs3/Emu/RSX/RSXFIFO.cpp +++ b/rpcs3/Emu/RSX/RSXFIFO.cpp @@ -160,7 +160,7 @@ namespace rsx // Validate the args ptr if the command attempts to read from it m_args_ptr = m_iotable->get_addr(m_internal_get + 4); - if (m_args_ptr == -1) [[unlikely]] + if (m_args_ptr == umax) [[unlikely]] { // Optional recovery data.reg = FIFO_ERROR; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 68ced1074c..27cd45b310 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1023,7 +1023,7 @@ namespace rsx // NOTE: surface_target_a is index 1 but is not MRT since only one surface is active bool color_write_enabled = false; - for (int i = 0; i < mrt_buffers.size(); ++i) + for (uint i = 0; i < mrt_buffers.size(); ++i) { if (rsx::method_registers.color_write_enabled(i)) { @@ -3089,7 +3089,7 @@ namespace rsx if (!sync_address) { - if (hint || ptimer->async_tasks_pending >= max_safe_queue_depth) + if (hint || ptimer->async_tasks_pending + 0u >= max_safe_queue_depth) { // Prepare the whole queue for reading. This happens when zcull activity is disabled or queue is too long for (auto It = m_pending_writes.rbegin(); It != m_pending_writes.rend(); ++It) diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp index 5e1a307fe4..1239a9c6dc 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp @@ -102,7 +102,7 @@ void VKFragmentDecompilerThread::insertOutputs(std::stringstream & OS) u8 output_index = 0; const bool float_type = (m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) || !device_props.has_native_half_support; const auto reg_type = float_type ? "vec4" : getHalfTypeName(4); - for (int i = 0; i < std::size(table); ++i) + for (uint i = 0; i < std::size(table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, reg_type, table[i].second)) { diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 99bed151f0..af88095362 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -2342,7 +2342,7 @@ bool VKGSRender::load_program() if (rsx::method_registers.cull_face_enabled()) properties.state.enable_cull_face(vk::get_cull_face(rsx::method_registers.cull_face_mode())); - for (int index = 0; index < m_draw_buffers.size(); ++index) + for (uint index = 0; index < m_draw_buffers.size(); ++index) { bool color_mask_b = rsx::method_registers.color_mask_b(index); bool color_mask_g = rsx::method_registers.color_mask_g(index); diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 89902d16fe..001bedf639 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -1827,7 +1827,7 @@ private: if (fbo_images.size() != attachments.size()) return false; - for (int n = 0; n < fbo_images.size(); ++n) + for (uint n = 0; n < fbo_images.size(); ++n) { if (attachments[n]->info.image != fbo_images[n]->value || attachments[n]->info.format != fbo_images[n]->info.format) diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.h b/rpcs3/Emu/RSX/VK/VKOverlays.h index 93045d915a..f9081e82cd 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.h +++ b/rpcs3/Emu/RSX/VK/VKOverlays.h @@ -288,7 +288,7 @@ namespace vk program->bind_uniform({ m_ubo.heap->value, m_ubo_offset, std::max(m_ubo_length, 4u) }, 0, m_descriptor_set); - for (int n = 0; n < src.size(); ++n) + for (uint n = 0; n < src.size(); ++n) { VkDescriptorImageInfo info = { m_sampler->value, src[n]->value, src[n]->image()->current_layout }; program->bind_uniform(info, "fs" + std::to_string(n), VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, m_descriptor_set); diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index bddd7ecce7..4f562c9aa6 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -349,8 +349,8 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) // Check swapchain condition/status if (!m_swapchain->supports_automatic_wm_reports()) { - if (m_swapchain_dims.width != m_frame->client_width() || - m_swapchain_dims.height != m_frame->client_height()) + if (m_swapchain_dims.width != m_frame->client_width() + 0u || + m_swapchain_dims.height != m_frame->client_height() + 0u) { swapchain_unavailable = true; } diff --git a/rpcs3/Emu/RSX/VK/VKTextOut.h b/rpcs3/Emu/RSX/VK/VKTextOut.h index c363274718..2e67f06aca 100644 --- a/rpcs3/Emu/RSX/VK/VKTextOut.h +++ b/rpcs3/Emu/RSX/VK/VKTextOut.h @@ -357,7 +357,7 @@ namespace vk vkCmdBeginRenderPass(cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); - for (int i = 0; i < counts.size(); ++i) + for (uint i = 0; i < counts.size(); ++i) { vkCmdDraw(cmd, counts[i], 1, offsets[i], i); } diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 30573161b6..1c6756707b 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -217,7 +217,7 @@ namespace rsx const u32 addr = rsx->iomap_table.get_addr(0xf100000 + (index * 0x40)); - verify(HERE), addr != -1; + verify(HERE), addr != umax; vm::_ref>(addr).store( { @@ -1346,7 +1346,7 @@ namespace rsx u32 dst_offset = method_registers.nv0039_output_offset(); u32 dst_dma = method_registers.nv0039_output_location(); - const bool is_block_transfer = (in_pitch == out_pitch && out_pitch == line_length); + const bool is_block_transfer = (in_pitch == out_pitch && out_pitch + 0u == line_length); const auto read_address = get_address(src_offset, src_dma, HERE); const auto write_address = get_address(dst_offset, dst_dma, HERE); const auto data_length = in_pitch * (line_count - 1) + line_length; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 23d24e5d9c..91cb14f2ab 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -985,7 +985,7 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa const std::string hdd0_disc = vfs::get("/dev_hdd0/disc/"); const std::size_t game_dir_size = 8; // size of PS3_GAME and PS3_GMXX const std::size_t bdvd_pos = m_cat == "DG" && bdvd_dir.empty() && disc.empty() ? elf_dir.rfind("/USRDIR") - game_dir_size : 0; - const bool from_hdd0_game = m_path.find(hdd0_game) != -1; + const bool from_hdd0_game = m_path.find(hdd0_game) != umax; if (bdvd_pos && from_hdd0_game) { diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index ea09c7b1e3..9408285aab 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -58,7 +58,7 @@ bool vfs::mount(std::string_view vpath, std::string_view path) return false; } - if (pos == -1) + if (pos == umax) { // Mounting completed list.back()->path = path; @@ -146,7 +146,7 @@ std::string vfs::get(std::string_view vpath, std::vector* out_dir, return fs::get_config_dir() + "delete_this_dir.../delete_this..."; } - if (pos == -1) + if (pos == umax) { // Absolute path: finalize for (auto it = list.rbegin(), rend = list.rend(); it != rend; it++) diff --git a/rpcs3/Input/ds3_pad_handler.cpp b/rpcs3/Input/ds3_pad_handler.cpp index 2b8b6f069b..8c67651cd8 100644 --- a/rpcs3/Input/ds3_pad_handler.cpp +++ b/rpcs3/Input/ds3_pad_handler.cpp @@ -163,7 +163,7 @@ void ds3_pad_handler::SetPadData(const std::string& padId, u32 largeMotor, u32 s device->small_motor = smallMotor; int index = 0; - for (int i = 0; i < MAX_GAMEPADS; i++) + for (uint i = 0; i < MAX_GAMEPADS; i++) { if (g_cfg_input.player[i]->handler == pad_handler::ds3) { @@ -222,7 +222,7 @@ std::shared_ptr ds3_pad_handler::get_ds3_device(con return nullptr; int pad_number = std::stoi(padId.substr(pos + 9)); - if (pad_number > 0 && pad_number <= controllers.size()) + if (pad_number > 0 && pad_number + 0u <= controllers.size()) return controllers[static_cast(pad_number) - 1]; return nullptr; diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index 5499f45975..b0cff5460d 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -192,7 +192,7 @@ void ds4_pad_handler::SetPadData(const std::string& padId, u32 largeMotor, u32 s device->smallVibrate = smallMotor; int index = 0; - for (int i = 0; i < MAX_GAMEPADS; i++) + for (uint i = 0; i < MAX_GAMEPADS; i++) { if (g_cfg_input.player[i]->handler == pad_handler::ds4) { diff --git a/rpcs3/Input/evdev_joystick_handler.cpp b/rpcs3/Input/evdev_joystick_handler.cpp index 4f4acf5091..f71ead44a7 100644 --- a/rpcs3/Input/evdev_joystick_handler.cpp +++ b/rpcs3/Input/evdev_joystick_handler.cpp @@ -738,7 +738,7 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr& devic // Translate any corresponding keycodes to our normal DS3 buttons and triggers for (int i = 0; i < static_cast(pad->m_buttons.size()); i++) { - if (pad->m_buttons[i].m_keyCode != button_code) + if (pad->m_buttons[i].m_keyCode != button_code + 0u) continue; // Be careful to handle mapped axis specially @@ -773,7 +773,7 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr& devic bool pressed_max = false; // m_keyCodeMin is the mapped key for left or down - if (pad->m_sticks[idx].m_keyCodeMin == button_code) + if (pad->m_sticks[idx].m_keyCodeMin == button_code + 0u) { bool is_direction_min = false; @@ -799,7 +799,7 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr& devic } // m_keyCodeMax is the mapped key for right or up - if (pad->m_sticks[idx].m_keyCodeMax == button_code) + if (pad->m_sticks[idx].m_keyCodeMax == button_code + 0u) { bool is_direction_max = false; diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index 5eff3e5fc2..fe7c620322 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -633,7 +633,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: void keyboard_pad_handler::ThreadProc() { - for (int i = 0; i < bindings.size(); i++) + for (uint i = 0; i < bindings.size(); i++) { if (last_connection_status[i] == false) { diff --git a/rpcs3/cmake_modules/ConfigureCompiler.cmake b/rpcs3/cmake_modules/ConfigureCompiler.cmake index 4a9a71c328..7c7d77019e 100644 --- a/rpcs3/cmake_modules/ConfigureCompiler.cmake +++ b/rpcs3/cmake_modules/ConfigureCompiler.cmake @@ -29,6 +29,7 @@ else() add_compile_options(-fno-strict-aliasing) add_compile_options(-Werror=old-style-cast) + add_compile_options(-Werror=sign-compare) #TODO Clean the code so these are removed add_compile_options(-Wno-unused-variable) diff --git a/rpcs3/rpcs3qt/debugger_frame.cpp b/rpcs3/rpcs3qt/debugger_frame.cpp index bb15e84437..1f3c2fc61b 100644 --- a/rpcs3/rpcs3qt/debugger_frame.cpp +++ b/rpcs3/rpcs3qt/debugger_frame.cpp @@ -272,7 +272,7 @@ void debugger_frame::UpdateUI() if (!cpu) { - if (m_last_pc != -1 || m_last_stat) + if (m_last_pc != umax || m_last_stat) { m_last_pc = -1; m_last_stat = 0; @@ -392,7 +392,7 @@ void debugger_frame::OnSelectUnit() void debugger_frame::DoUpdate() { // Check if we need to disable a step over bp - if (m_last_step_over_breakpoint != -1 && GetPc() == m_last_step_over_breakpoint) + if (m_last_step_over_breakpoint != umax && GetPc() == m_last_step_over_breakpoint) { m_breakpoint_handler->RemoveBreakpoint(m_last_step_over_breakpoint); m_last_step_over_breakpoint = -1; @@ -589,7 +589,7 @@ void debugger_frame::DoStep(bool stepOver) // Undefine previous step over breakpoint if it hasnt been already // This can happen when the user steps over a branch that doesn't return to itself - if (m_last_step_over_breakpoint != -1) + if (m_last_step_over_breakpoint != umax) { m_breakpoint_handler->RemoveBreakpoint(next_instruction_pc); } diff --git a/rpcs3/rpcs3qt/log_frame.cpp b/rpcs3/rpcs3qt/log_frame.cpp index 336ff57f27..46bc6eb616 100644 --- a/rpcs3/rpcs3qt/log_frame.cpp +++ b/rpcs3/rpcs3qt/log_frame.cpp @@ -438,7 +438,7 @@ void log_frame::UpdateUI() buf.resize(size); buf.resize(m_tty_file.read(&buf.front(), buf.size())); - if (buf.find_first_of('\0') != -1) + if (buf.find_first_of('\0') != umax) { m_tty_file.seek(s64{0} - buf.size(), fs::seek_mode::seek_cur); break; diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.cpp b/rpcs3/rpcs3qt/msg_dialog_frame.cpp index d4684d6d36..866517020a 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/msg_dialog_frame.cpp @@ -218,7 +218,7 @@ void msg_dialog_frame::ProgressBarReset(u32 index) m_gauge2->setValue(0); } - if (index == taskbar_index) + if (index == taskbar_index + 0u) { #ifdef _WIN32 if (m_tb_progress) @@ -248,7 +248,7 @@ void msg_dialog_frame::ProgressBarInc(u32 index, u32 delta) m_gauge2->setValue(std::min(m_gauge2->value() + static_cast(delta), m_gauge2->maximum())); } - if (index == taskbar_index || taskbar_index == -1) + if (index == taskbar_index + 0u || taskbar_index == -1) { #ifdef _WIN32 if (m_tb_progress) @@ -281,7 +281,7 @@ void msg_dialog_frame::ProgressBarSetLimit(u32 index, u32 limit) bool set_taskbar_limit = false; - if (index == taskbar_index) + if (index == taskbar_index + 0u) { m_gauge_max = limit; set_taskbar_limit = true; diff --git a/rpcs3/rpcs3qt/register_editor_dialog.cpp b/rpcs3/rpcs3qt/register_editor_dialog.cpp index ed6715abf6..a8b6a0725d 100644 --- a/rpcs3/rpcs3qt/register_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/register_editor_dialog.cpp @@ -98,7 +98,7 @@ void register_editor_dialog::updateRegister(const QString& text) auto& ppu = *static_cast(cpu.get()); std::size_t first_brk = reg.find('['); - if (first_brk != -1) + if (first_brk != umax) { long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str()); if (reg.starts_with("GPR")) str = fmt::format("%016llx", ppu.gpr[reg_index]); @@ -140,7 +140,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _cpu) const auto first_brk = reg.find('['); try { - if (first_brk != -1) + if (first_brk != umax) { const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str()); if (reg.starts_with("GPR") || reg.starts_with("FPR")) @@ -185,7 +185,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _cpu) const auto first_brk = reg.find('['); try { - if (first_brk != -1) + if (first_brk != umax) { const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - 2).c_str()); if (reg.starts_with("GPR")) diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp index a3d7a48afa..d239e69f95 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp @@ -596,7 +596,7 @@ void trophy_manager_dialog::ApplyFilter() return; const int db_pos = m_game_combo->currentData().toInt(); - if (db_pos >= m_trophies_db.size() || !m_trophies_db[db_pos]) + if (db_pos + 0u >= m_trophies_db.size() || !m_trophies_db[db_pos]) return; const auto trop_usr = m_trophies_db[db_pos]->trop_usr.get(); diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index 7ac63e3ffb..13c5304592 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -274,7 +274,7 @@ bool update_manager::handle_json(const QByteArray& data, bool automatic) bool update_manager::handle_rpcs3(const QByteArray& rpcs3_data, bool /*automatic*/) { - if (m_expected_size != rpcs3_data.size()) + if (m_expected_size != rpcs3_data.size() + 0u) { update_log.error("[Auto-updater] Download size mismatch: %d expected: %d", rpcs3_data.size(), m_expected_size); return false; @@ -340,7 +340,7 @@ bool update_manager::handle_rpcs3(const QByteArray& rpcs3_data, bool /*automatic update_log.error("[Auto-updater] Failed to create new AppImage file: %s", replace_path); return false; } - if (new_appimage.write(rpcs3_data.data(), rpcs3_data.size()) != rpcs3_data.size()) + if (new_appimage.write(rpcs3_data.data(), rpcs3_data.size()) != rpcs3_data.size() + 0u) { update_log.error("[Auto-updater] Failed to write new AppImage file: %s", replace_path); return false; diff --git a/rpcs3/util/atomic2.cpp b/rpcs3/util/atomic2.cpp index 5eaa4e2c0b..1218502f2c 100644 --- a/rpcs3/util/atomic2.cpp +++ b/rpcs3/util/atomic2.cpp @@ -332,7 +332,7 @@ bool stx::multi_cas_record::commit() const noexcept cmp.m_data[0] = item.m_old; cmp.m_data[1] = id; - if (item.m_addr->load() == item.m_old && atomic_storage::load(item.m_addr->m_data[1]) == id) + if (item.m_addr->load() == item.m_old && atomic_storage::load(item.m_addr->m_data[1]) == static_cast(id)) { if (cmpxchg16(item.m_addr->m_data, cmp.m_data, 0, item.m_new)) { @@ -403,7 +403,7 @@ bool stx::multi_cas_record::commit() const noexcept { return true; } - else if (cmp.m_data[0] != m_list[0].m_old) + else if (cmp.m_data[0] != static_cast(m_list[0].m_old)) { return false; } @@ -472,7 +472,7 @@ bool stx::multi_cas_record::commit() const noexcept { break; } - else if (cmp.m_data[0] != m_list[i].m_old) + else if (cmp.m_data[0] != static_cast(m_list[i].m_old)) { s_records[id].m_state |= s_state_failure; break; @@ -514,7 +514,7 @@ bool stx::multi_cas_record::commit() const noexcept cmp.m_data[0] = item.m_old; cmp.m_data[1] = id; - if (item.m_addr->load() == item.m_old && atomic_storage::load(item.m_addr->m_data[1]) == id) + if (item.m_addr->load() == item.m_old && atomic_storage::load(item.m_addr->m_data[1]) == static_cast(id)) { // Restore old or set new if (cmpxchg16(item.m_addr->m_data, cmp.m_data, 0, ok ? item.m_new : item.m_old))