diff --git a/rpcs3/Emu/Cell/Modules/cellGifDec.cpp b/rpcs3/Emu/Cell/Modules/cellGifDec.cpp index 448f86003a..80242686cb 100644 --- a/rpcs3/Emu/Cell/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGifDec.cpp @@ -273,7 +273,7 @@ error_code cellGifDecReadHeader(vm::ptr mainHandle, vm::ptrfd; + const u32 fd = subHandle->fd; CellGifDecInfo& current_info = subHandle->info; // Write the header to buffer @@ -302,7 +302,7 @@ error_code cellGifDecReadHeader(vm::ptr mainHandle, vm::ptr> 7; @@ -520,8 +520,8 @@ error_code cellGifDecDecodeData(vm::ptr mainHandle, vm::cptr(dataCtrlParam->outputBytesPerLine); - const char nComponents = 4; - uint image_size = width * height * nComponents; + constexpr char nComponents = 4; + const u32 image_size = width * height * nComponents; switch(current_outParam.outputColorSpace) { @@ -541,9 +541,8 @@ error_code cellGifDecDecodeData(vm::ptr mainHandle, vm::cptr width * nComponents) // Check if we need padding @@ -579,9 +578,8 @@ error_code cellGifDecDecodeData(vm::ptr mainHandle, vm::cptr out, u32 outSize, vm::cptr in for (u32 pos = 0; rindex >= 0; rindex--, pos++) { - char c1 = in[pos]; + const char c1 = in[pos]; if (false) // DAT[c1] == '\x03') // TODO { @@ -529,7 +529,7 @@ error_code cellHttpUtilEscapeUri(vm::ptr out, u32 outSize, vm::cptr in return CELL_HTTP_UTIL_ERROR_NO_MEMORY; } - const char* chars = "0123456789ABCDEF"; + constexpr const char* chars = "0123456789ABCDEF"; out[out_pos++] = '%'; // 0x25 out[out_pos++] = chars[c1 >> 4]; out[out_pos++] = chars[c1 & 0xf]; @@ -618,7 +618,7 @@ error_code cellHttpUtilFormUrlEncode(vm::ptr out, u32 outSize, vm::cptr= 0; rindex--, pos++) { - char c1 = in[pos]; + const char c1 = in[pos]; if (c1 == ' ') { @@ -645,7 +645,7 @@ error_code cellHttpUtilFormUrlEncode(vm::ptr out, u32 outSize, vm::cptr> 4]; out[out_pos++] = chars[c1 & 0xf]; @@ -707,7 +707,7 @@ error_code cellHttpUtilFormUrlDecode(vm::ptr out, u32 size, vm::cptr i for (s32 index = 0, pos = 0;; index++) { size_needed = index + 1; - char c1 = in[pos++]; + const char c1 = in[pos++]; if (!c1) { @@ -731,7 +731,7 @@ error_code cellHttpUtilFormUrlDecode(vm::ptr out, u32 size, vm::cptr i const auto check_char = [](b8 c) { - u32 utmp = static_cast(c); + const u32 utmp = static_cast(c); s32 stmp = utmp - 48; if (static_cast(c - 48) > 9) { diff --git a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp index 82ec56727a..124531826d 100644 --- a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp @@ -76,7 +76,7 @@ error_code cellJpgDecOpen(u32 mainHandle, vm::ptr subHandle, vm::ptrfileName.get_ptr()); + const std::string real_path = vfs::get(src->fileName.get_ptr()); fs::file file_s(real_path); if (!file_s) return CELL_JPGDEC_ERROR_OPEN_FILE; @@ -127,8 +127,8 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptrfd; - const u64& fileSize = subHandle_data->fileSize; + const u32 fd = subHandle_data->fd; + const u64 fileSize = subHandle_data->fileSize; CellJpgDecInfo& current_info = subHandle_data->info; // Write the header to buffer @@ -158,12 +158,12 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr= fileSize) + if (i >= fileSize) return CELL_JPGDEC_ERROR_HEADER; - u16 block_length = buffer[i] * 0xFF + buffer[i+1]; + u16 block_length = buffer[i] * 0xFF + buffer[i + 1]; - while(true) + while (true) { i += block_length; // Increase the file index to get to the next block if (i >= fileSize || // Check to protect against segmentation faults @@ -172,15 +172,15 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr data, { memcpy(data.get_ptr(), image.get(), image_size); } + break; } - break; - case CELL_JPG_ARGB: { - const int nComponents = 4; + constexpr int nComponents = 4; image_size *= nComponents; if (bytesPerLine > width * nComponents || flip) //check if we need padding { @@ -307,16 +306,15 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr data, } std::memcpy(data.get_ptr(), img.get(), image_size); } + break; } - break; - case CELL_JPG_GRAYSCALE: case CELL_JPG_YCbCr: case CELL_JPG_UPSAMPLE_ONLY: case CELL_JPG_GRAYSCALE_TO_ALPHA_RGBA: case CELL_JPG_GRAYSCALE_TO_ALPHA_ARGB: cellJpgDec.error("cellJpgDecDecodeData: Unsupported color space (%d)", current_outParam.outputColorSpace); - break; + break; default: return CELL_JPGDEC_ERROR_ARG; @@ -324,7 +322,7 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr data, dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_FINISH; - if(dataCtrlParam->outputBytesPerLine) + if (dataCtrlParam->outputBytesPerLine) dataOutInfo->outputLines = static_cast(image_size / dataCtrlParam->outputBytesPerLine); return CELL_OK; diff --git a/rpcs3/Emu/Cell/lv2/sys_cond.cpp b/rpcs3/Emu/Cell/lv2/sys_cond.cpp index 840b1942b7..bcfe83aed3 100644 --- a/rpcs3/Emu/Cell/lv2/sys_cond.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_cond.cpp @@ -60,7 +60,6 @@ CellError lv2_cond::on_id_create() if (!mutex) { _mutex = static_cast>(ensure(idm::get_unlocked(mtx_id))); - } // Defer function diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 23f932ae91..3cb8e8eb2f 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -79,7 +79,7 @@ void fmt_class_string::format(std::string& out, u64 arg) const usz pos = file.file ? file.file.pos() : umax; const usz size = file.file ? file.file.size() : umax; - fmt::append(out, u8"%s, “%s”, Mode: 0x%x, Flags: 0x%x, Pos/Size: %s/%s (0x%x/0x%x)", file.type, file.name.data(), file.mode, file.flags, get_size(pos), get_size(size), pos, size); + fmt::append(out, u8"%s, '%s', Mode: 0x%x, Flags: 0x%x, Pos/Size: %s/%s (0x%x/0x%x)", file.type, file.name.data(), file.mode, file.flags, get_size(pos), get_size(size), pos, size); } template<> @@ -87,7 +87,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { const auto& dir = get_object(arg); - fmt::append(out, u8"Directory, “%s”, Entries: %u/%u", dir.name.data(), std::min(dir.pos, dir.entries.size()), dir.entries.size()); + fmt::append(out, u8"Directory, '%s', Entries: %u/%u", dir.name.data(), std::min(dir.pos, dir.entries.size()), dir.entries.size()); } bool has_fs_write_rights(std::string_view vpath) diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index ffde4f6ce7..bf128a393f 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -559,10 +559,8 @@ class idm place = object; return object; } - else - { - key_ptr->clear(); - } + + *key_ptr = {}; } return {}; diff --git a/rpcs3/Input/ps_move_handler.h b/rpcs3/Input/ps_move_handler.h index 0a6939e6f8..4c6097fecf 100644 --- a/rpcs3/Input/ps_move_handler.h +++ b/rpcs3/Input/ps_move_handler.h @@ -55,7 +55,7 @@ namespace reports // ID Size Description u8 magnetometer_x2{}; // 0x27 1- X-axis magnetometer u8 magnetometer_y{}; // 0x28 1+ Y-axis magnetometer - u8 magnetometer_yz{}; // 0x29 1 XZ-axis magnetometer + u8 magnetometer_yz{}; // 0x29 1 YZ-axis magnetometer u8 magnetometer_z{}; // 0x2A 1- Z-axis magnetometer u8 timestamp_lower{}; // 0x2B 1 Timestamp (lower byte) std::array ext_device_data{}; // 0x2C 5 External device data