diff --git a/Utilities/CPUStats.h b/Utilities/CPUStats.h index 97a1e60af8..b4015e2e8f 100644 --- a/Utilities/CPUStats.h +++ b/Utilities/CPUStats.h @@ -174,7 +174,7 @@ public: 1, #endif }; - u_int miblen = sizeof(mib) / sizeof(mib[0]); + u_int miblen = std::size(mib); struct kinfo_proc info; size_t size = sizeof(info); if (sysctl(mib, miblen, &info, &size, NULL, 0)) @@ -191,7 +191,7 @@ public: sizeof(struct kinfo_proc), 0, }; - u_int miblen = sizeof(mib) / sizeof(mib[0]); + u_int miblen = std::size(mib); // get number of structs size_t size; diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index 0770ea082a..0a1204cc29 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -139,7 +139,7 @@ void audio_config::on_task() { if (first_mix) { - for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2) + for (u32 i = 0; i < std::size(buf2ch); i += 2) { step_volume(port); @@ -163,7 +163,7 @@ void audio_config::on_task() } else { - for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2) + for (u32 i = 0; i < std::size(buf2ch); i += 2) { step_volume(port); @@ -182,7 +182,7 @@ void audio_config::on_task() { if (first_mix) { - for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2) + for (u32 i = 0; i < std::size(buf2ch); i += 2) { step_volume(port); @@ -212,7 +212,7 @@ void audio_config::on_task() } else { - for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2) + for (u32 i = 0; i < std::size(buf2ch); i += 2) { step_volume(port); @@ -254,14 +254,14 @@ void audio_config::on_task() // Copy output data (2ch or 8ch) if (g_cfg.audio.downmix_to_2ch) { - for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i++) + for (u32 i = 0; i < std::size(buf2ch); i++) { out_buffer[out_pos][i] = buf2ch[i]; } } else { - for (u32 i = 0; i < (sizeof(buf8ch) / sizeof(float)); i++) + for (u32 i = 0; i < std::size(buf8ch); i++) { out_buffer[out_pos][i] = buf8ch[i]; } diff --git a/rpcs3/Emu/Cell/Modules/cellDmux.cpp b/rpcs3/Emu/Cell/Modules/cellDmux.cpp index 79e3462874..c0124bd90c 100644 --- a/rpcs3/Emu/Cell/Modules/cellDmux.cpp +++ b/rpcs3/Emu/Cell/Modules/cellDmux.cpp @@ -514,7 +514,7 @@ public: if (task.stream.discontinuity) { cellDmux.warning("dmuxSetStream (beginning)"); - for (u32 i = 0; i < sizeof(esALL) / sizeof(esALL[0]); i++) + for (u32 i = 0; i < std::size(esALL); i++) { if (esALL[i]) { @@ -595,7 +595,7 @@ public: fmt::throw_exception("dmuxDisableEs: invalid elementary stream" HERE); } - for (u32 i = 0; i < sizeof(esALL) / sizeof(esALL[0]); i++) + for (u32 i = 0; i < std::size(esALL); i++) { if (esALL[i] == &es) { diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index aa22df2842..11aa84253b 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -324,7 +324,7 @@ u32 cellGcmGetTiledPitchSize(u32 size) { cellGcmSys.trace("cellGcmGetTiledPitchSize(size=%d)", size); - for (size_t i = 0; i < sizeof(tiled_pitches) / sizeof(tiled_pitches[0]) - 1; i++) { + for (size_t i = 0; i < std::size(tiled_pitches) - 1; i++) { if (tiled_pitches[i] < size && size <= tiled_pitches[i + 1]) { return tiled_pitches[i + 1]; } diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 147dc58ee7..dec5f73c3f 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -365,7 +365,7 @@ spu_imm_table_t::scale_table_t::scale_table_t() spu_imm_table_t::spu_imm_table_t() { - for (u32 i = 0; i < sizeof(sldq_pshufb) / sizeof(sldq_pshufb[0]); i++) + for (u32 i = 0; i < std::size(sldq_pshufb); i++) { for (u32 j = 0; j < 16; j++) { @@ -373,7 +373,7 @@ spu_imm_table_t::spu_imm_table_t() } } - for (u32 i = 0; i < sizeof(srdq_pshufb) / sizeof(srdq_pshufb[0]); i++) + for (u32 i = 0; i < std::size(srdq_pshufb); i++) { const u32 im = (0u - i) & 0x1f; @@ -383,7 +383,7 @@ spu_imm_table_t::spu_imm_table_t() } } - for (u32 i = 0; i < sizeof(rldq_pshufb) / sizeof(rldq_pshufb[0]); i++) + for (u32 i = 0; i < std::size(rldq_pshufb); i++) { for (u32 j = 0; j < 16; j++) { diff --git a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp index 2e9857c2ee..ca1e9b1571 100644 --- a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp @@ -178,7 +178,7 @@ template std::string CgBinaryDisasm::GetSrcDisAsm(T src) { case 0x00: ret += reg_table[0]; break; default: - if (dst.src_attr_reg_num < sizeof(reg_table) / sizeof(reg_table[0])) + if (dst.src_attr_reg_num < std::size(reg_table)) { ret += fmt::format("%s[%s]", perspective_correction.c_str(), input_attr_reg.c_str()); } diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index fb54423711..c8c800903b 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -444,7 +444,7 @@ template std::string FragmentProgramDecompiler::GetSRC(T src) properties.has_wpos_input = true; break; default: - if (dst.src_attr_reg_num < sizeof(reg_table) / sizeof(reg_table[0])) + if (dst.src_attr_reg_num < std::size(reg_table)) { ret += m_parr.AddParam(PF_PARAM_IN, getFloatTypeName(4), reg_table[dst.src_attr_reg_num]); } diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp index 0ee8fbac40..724fd205dd 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp @@ -82,7 +82,7 @@ std::string VertexProgramDecompiler::GetSRC(const u32 n) ret += m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "tmp" + std::to_string(src[n].tmp_src)); break; case RSX_VP_REGISTER_TYPE_INPUT: - if (d1.input_src < (sizeof(reg_table) / sizeof(reg_table[0]))) + if (d1.input_src < std::size(reg_table)) { ret += m_parr.AddParam(PF_PARAM_IN, getFloatTypeName(4), reg_table[d1.input_src], d1.input_src); } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp index 88b8cadf4e..c510ffe760 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp @@ -92,7 +92,7 @@ void D3D12FragmentDecompiler::insertOutputs(std::stringstream & OS) { "ocol3", m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS ? "r4" : "h8" }, }; size_t idx = 0; - for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) + for (int i = 0; i < std::size(table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second)) OS << " " << "float4" << " " << table[i].first << " : SV_TARGET" << idx++ << ";\n"; @@ -294,7 +294,7 @@ void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS) std::string first_output_name; OS << " PixelOutput Out = (PixelOutput)0;\n"; - for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) + for (int i = 0; i < std::size(table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second)) { diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index ca6439a2e6..1ca0a87aca 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -92,7 +92,7 @@ void GLFragmentDecompilerThread::insertOutputs(std::stringstream & OS) { "ocol3", m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS ? "r4" : "h8" }, }; - for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) + for (int i = 0; i < std::size(table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second)) OS << "layout(location=" << i << ") out vec4 " << table[i].first << ";\n"; diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp index a0f14d39ce..db907b66f8 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp @@ -93,7 +93,7 @@ void VKFragmentDecompilerThread::insertOutputs(std::stringstream & OS) //NOTE: We do not skip outputs, the only possible combinations are a(0), b(0), ab(0,1), abc(0,1,2), abcd(0,1,2,3) u8 output_index = 0; - for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) + for (int i = 0; i < std::size(table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second)) {