Skip to content

Commit

Permalink
decrease C_style cast
Browse files Browse the repository at this point in the history
  • Loading branch information
nishinji committed Aug 22, 2024
1 parent 3f62275 commit 8801e7f
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion vita3k/Windows.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--
Vita3K emulator project
Copyright (C) 2021 Vita3K team
Copyright (C) 2024 Vita3K team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions vita3k/config/include/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ enum ScreenshotFormat {
code(bool, "ngs-enable", true, ngs_enable) \
code(int, "sys-button", static_cast<int>(SCE_SYSTEM_PARAM_ENTER_BUTTON_CROSS), sys_button) \
code(int, "sys-lang", static_cast<int>(SCE_SYSTEM_PARAM_LANG_ENGLISH_US), sys_lang) \
code(int, "sys-date-format", (int)SCE_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY, sys_date_format) \
code(int, "sys-time-format", (int)SCE_SYSTEM_PARAM_TIME_FORMAT_12HOUR, sys_time_format) \
code(int, "sys-date-format",static_cast<int>(SCE_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY), sys_date_format)\
code(int, "sys-time-format", static_cast<int>(SCE_SYSTEM_PARAM_TIME_FORMAT_12HOUR), sys_time_format)\
code(int, "cpu-pool-size", 10, cpu_pool_size) \
code(int, "modules-mode", static_cast<int>(ModulesMode::AUTOMATIC), modules_mode) \
code(int, "delay-background", 4, delay_background) \
Expand Down
2 changes: 1 addition & 1 deletion vita3k/gui/src/manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void draw_manual(GuiState &gui, EmuEnvState &emuenv) {
}

// Draw right button
if (current_page < (int)gui.manuals.size() - 1) {
if (current_page < static_cast<int>(gui.manuals.size()) - 1) {
ImGui::SetCursorPos(ImVec2(display_size.x - (70.f * SCALE.x), display_size.y - (40.0f * SCALE.y)));
if ((!hidden_button && ImGui::Button(">", BUTTON_SIZE)) || ImGui::IsKeyPressed(static_cast<ImGuiKey>(emuenv.cfg.keyboard_leftstick_right))) {
scroll = 0.f;
Expand Down
6 changes: 3 additions & 3 deletions vita3k/gui/src/trophy_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ static bool load_trophy_progress(IOState &io, const SceUID &progress_input_file,
}

// Read trophy count by group
if (read_trophy_progress_file(np_com_id_info[np_com_id].context.trophy_count_by_group.data(), (uint32_t)np_com_id_info[np_com_id].context.trophy_count_by_group.size() * 4) != (int)np_com_id_info[np_com_id].context.trophy_count_by_group.size() * 4) {
if (read_trophy_progress_file(np_com_id_info[np_com_id].context.trophy_count_by_group.data(), (uint32_t)np_com_id_info[np_com_id].context.trophy_count_by_group.size() * 4) != static_cast<int>(np_com_id_info[np_com_id].context.trophy_count_by_group.size()) * 4) {
LOG_ERROR("Fail read trophy count by group");
return false;
}

// Read trophy timestamps
if (read_trophy_progress_file(np_com_id_info[np_com_id].context.unlock_timestamps.data(), (uint32_t)np_com_id_info[np_com_id].context.unlock_timestamps.size() * 8) != (int)np_com_id_info[np_com_id].context.unlock_timestamps.size() * 8) {
if (read_trophy_progress_file(np_com_id_info[np_com_id].context.unlock_timestamps.data(), (uint32_t)np_com_id_info[np_com_id].context.unlock_timestamps.size() * 8) != static_cast<int>(np_com_id_info[np_com_id].context.unlock_timestamps.size()) * 8) {
LOG_ERROR("Fail read unlock_timestamp");
return false;
}

// Read trophy type
if (read_trophy_progress_file(np_com_id_info[np_com_id].context.trophy_kinds.data(), (uint32_t)np_com_id_info[np_com_id].context.trophy_kinds.size() * 4) != (int)np_com_id_info[np_com_id].context.trophy_kinds.size() * 4) {
if (read_trophy_progress_file(np_com_id_info[np_com_id].context.trophy_kinds.data(), (uint32_t)np_com_id_info[np_com_id].context.trophy_kinds.size() * 4) != static_cast<int>(np_com_id_info[np_com_id].context.trophy_kinds.size()) * 4) {
LOG_ERROR("Fail read trophy type");
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion vita3k/kernel/src/sync_primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ SceSize msgpipe_send(KernelState &kernel, const char *export_name, SceUID thread
SceSize insertedSize = (SceSize)msgpipe->data_buffer.Insert(pSendBuf, sendSize);
// msgpipe->senders->erase(wait_data); //Don't erase ourselves - recv will do it
wakeup_receivers();
return (int)insertedSize;
return static_cast<int>(insertedSize);
};

if (!pTimeout) { // No timeout - loop forever until we can fill the buffer
Expand Down
8 changes: 4 additions & 4 deletions vita3k/modules/SceHttp/SceHttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ EXPORT(SceInt, sceHttpCreateConnectionWithURL, SceInt tmplId, const char *url, S
}
case SCE_HTTP_ERROR_OUT_OF_SIZE: return RET_ERROR(SCE_HTTP_ERROR_OUT_OF_SIZE);
default:
LOG_WARN("Returning missing case of parse_url {}", (int)parseRet);
LOG_WARN("Returning missing case of parse_url {}", static_cast<int>(parseRet));
assert(false);
return parseRet;
}
Expand Down Expand Up @@ -332,7 +332,7 @@ EXPORT(SceInt, sceHttpCreateConnectionWithURL, SceInt tmplId, const char *url, S

long verify_flag = SSL_get_verify_result((SSL *)tmpl->second.ssl);
if (verify_flag != X509_V_OK && verify_flag != X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY)
LOG_ERROR("Certificate verification error ({}) but continuing...\n", (int)verify_flag);
LOG_ERROR("Certificate verification error ({}) but continuing...\n", static_cast<int>(verify_flag));
}

emuenv.http.connections.emplace(connId, SceConnection{ tmplId, urlStr, enableKeepalive, isSecure, sockfd });
Expand Down Expand Up @@ -411,7 +411,7 @@ EXPORT(SceInt, sceHttpCreateRequestWithURL, SceInt connId, SceHttpMethods method
}
case SCE_HTTP_ERROR_OUT_OF_SIZE: return RET_ERROR(SCE_HTTP_ERROR_OUT_OF_SIZE);
default:
LOG_WARN("Returning missing case of parse_url {}", (int)parseRet);
LOG_WARN("Returning missing case of parse_url {}", static_cast<int>(parseRet));
assert(false);
return parseRet;
}
Expand Down Expand Up @@ -1451,7 +1451,7 @@ EXPORT(SceInt, sceHttpUriParse, SceHttpUriElement *out, const char *srcUrl, Ptr<
}
case SCE_HTTP_ERROR_OUT_OF_SIZE: return RET_ERROR(SCE_HTTP_ERROR_OUT_OF_SIZE);
default:
LOG_WARN("Returning missing case of parse_url {}", (int)parseRet);
LOG_WARN("Returning missing case of parse_url {}", static_cast<int>(parseRet));
assert(false);
return parseRet;
}
Expand Down
2 changes: 1 addition & 1 deletion vita3k/modules/SceLibKernel/SceLibKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ EXPORT(Ptr<void>, sceClibMemcpy_safe, Ptr<void> dst, const Ptr<void> src, SceSiz
CALL_EXPORT(sceClibMemcpy, dst, src.get(emuenv.mem), len);
return dst;
}
const auto diff = std::abs((int)(src.address() - dst.address()));
const auto diff = std::abs(static_cast<int>(src.address() - dst.address()));
if (len > diff) {
LOG_ERROR("sceClibMemcpy({},{},{}) src/dst overlap", log_hex_full(src.address()), log_hex_full(dst.address()), len);
assert(false);
Expand Down
6 changes: 3 additions & 3 deletions vita3k/np/src/trophy/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ bool Context::load_trophy_progress_file(const SceUID &progress_input_file) {
return false;

// Read trophy count by group
if (read_stuff(trophy_count_by_group.data(), (std::uint32_t)trophy_count_by_group.size() * 4) != (int)trophy_count_by_group.size() * 4)
if (read_stuff(trophy_count_by_group.data(), static_cast<std::uint32_t>(trophy_count_by_group.size()) * 4) != static_cast<int>(trophy_count_by_group.size()) * 4)
return false;

// Read timestamps
if (read_stuff(unlock_timestamps.data(), (std::uint32_t)unlock_timestamps.size() * 8) != (int)unlock_timestamps.size() * 8)
if (read_stuff(unlock_timestamps.data(), static_cast<std::uint32_t>(unlock_timestamps.size()) * 8) != static_cast<int>(unlock_timestamps.size()) * 8)
return false;

// Read trophy type (shinyyyy!! *yes this is lord of the ring reference*)
if (read_stuff(trophy_kinds.data(), (std::uint32_t)trophy_kinds.size() * 4) != (int)trophy_kinds.size() * 4)
if (read_stuff(trophy_kinds.data(), static_cast<std::uint32_t>(trophy_kinds.size()) * 4) != static_cast<int>(trophy_kinds.size()) * 4)
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions vita3k/packages/src/sce_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static void traverse_directory(Fat16::Image &img, Fat16::Entry mee, const fs::pa
fs::create_directories(dir_path);

while (img.get_next_entry(mee)) {
if (mee.entry.file_attributes & (int)Fat16::EntryAttribute::DIRECTORY) {
if (mee.entry.file_attributes & static_cast<int>(Fat16::EntryAttribute::DIRECTORY)) {
// Also check if it's not the back folder (. and ..)
// This can be done by gathering the name
if (mee.entry.get_entry_type_from_filename() != Fat16::EntryType::DIRECTORY) {
Expand All @@ -646,7 +646,7 @@ static void traverse_directory(Fat16::Image &img, Fat16::Entry mee, const fs::pa
}
}

if (mee.entry.file_attributes & (int)Fat16::EntryAttribute::ARCHIVE) {
if (mee.entry.file_attributes & static_cast<int>(Fat16::EntryAttribute::ARCHIVE)) {
extract_file(img, mee, dir_path / "");
}
}
Expand Down
2 changes: 1 addition & 1 deletion vita3k/shader/src/gxp_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,4 @@ uint8_t get_texture_component_count(SceGxmTextureFormat format) {
}
}

} // namespace shader
} // namespace shader
2 changes: 1 addition & 1 deletion vita3k/shader/src/spirv_recompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ static SpirvShaderParameters create_parameters(spv::Builder &b, const SceGxmProg
// specialization constant for shader interlock:
// layout (constant_id = GAMMA_CORRECTION_SPECIALIZATION_ID) const bool is_srgb = false;
spv_params.is_srgb_constant = b.makeBoolConstant(false, true);
b.addDecoration(spv_params.is_srgb_constant, spv::DecorationSpecId, (int)GAMMA_CORRECTION_SPECIALIZATION_ID);
b.addDecoration(spv_params.is_srgb_constant, spv::DecorationSpecId, static_cast<int>(GAMMA_CORRECTION_SPECIALIZATION_ID));
b.addName(spv_params.is_srgb_constant, "is_srgb");
}
}
Expand Down
12 changes: 6 additions & 6 deletions vita3k/shader/src/translator/alu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,12 +913,12 @@ bool USSETranslatorVisitor::sop2(
inst.opr.dest.type = DataType::UINT8;

if (cop >= sizeof(operations) / sizeof(Opcode)) {
LOG_ERROR("Invalid color opcode: {}", (int)cop);
LOG_ERROR("Invalid color opcode: {}", static_cast<int>(cop));
return true;
}

if (aop >= sizeof(operations) / sizeof(Opcode)) {
LOG_ERROR("Invalid alpha opcode: {}", (int)aop);
LOG_ERROR("Invalid alpha opcode: {}", static_cast<int>(aop));
return true;
}

Expand Down Expand Up @@ -1127,12 +1127,12 @@ bool shader::usse::USSETranslatorVisitor::sop2m(Imm2 pred,
inst.opr.dest.type = DataType::UINT8;

if (cop >= sizeof(operations) / sizeof(Opcode)) {
LOG_ERROR("Invalid color opcode: {}", (int)cop);
LOG_ERROR("Invalid color opcode: {}", static_cast<int>(cop));
return true;
}

if (aop >= sizeof(operations) / sizeof(Opcode)) {
LOG_ERROR("Invalid alpha opcode: {}", (int)aop);
LOG_ERROR("Invalid alpha opcode: {}", static_cast<int>(aop));
return true;
}

Expand Down Expand Up @@ -1361,12 +1361,12 @@ bool shader::usse::USSETranslatorVisitor::sop3(Imm2 pred,
inst.opr.dest.type = DataType::UINT8;

if (cop >= sizeof(operations) / sizeof(Opcode)) {
LOG_ERROR("Invalid color opcode: {}", (int)cop);
LOG_ERROR("Invalid color opcode: {}", static_cast<int>(cop));
return true;
}

if (aop >= sizeof(operations) / sizeof(Opcode)) {
LOG_ERROR("Invalid alpha opcode: {}", (int)aop);
LOG_ERROR("Invalid alpha opcode: {}", static_cast<int>(aop));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion vita3k/shader/src/usse_disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ std::string reg_to_str(RegisterBank bank, uint32_t reg_num) {
}
}

opstr += "idx" + std::to_string((int)bank - (int)RegisterBank::INDEXED1 + 1) + " * 2 + " + std::to_string(add_off) + "]";
opstr += "idx" + std::to_string(static_cast<int>(bank) - static_cast<int>(RegisterBank::INDEXED1) + 1) + " * 2 + " + std::to_string(add_off) + "]";

break;
}
Expand Down
18 changes: 9 additions & 9 deletions vita3k/shader/src/usse_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ spv::Id finalize(spv::Builder &b, spv::Id first, spv::Id second, const Swizzle4
// Try to plant a composite construct
for (auto i = 0; i < 4; i++) {
if (dest_mask & (1 << i)) {
if ((int)swizz[i] >= (int)SwizzleChannel::C_0) {
if (static_cast<int>(swizz[i]) >= static_cast<int>(SwizzleChannel::C_0)) {
ops.push_back(get_correspond_constant_with_channel(b, swizz[i]));
} else if (offset_is_const) {
int access_offset = offset_value % 4 + (int)swizz[i] - (int)SwizzleChannel::C_X;
int access_offset = offset_value % 4 + static_cast<int>(swizz[i]) - static_cast<int>(SwizzleChannel::C_X);
spv::Id access_base = first;

if (access_offset >= first_comp_count) {
Expand All @@ -107,13 +107,13 @@ spv::Id finalize(spv::Builder &b, spv::Id first, spv::Id second, const Swizzle4
return spv::NoResult;
}
// do exactly as above, but in spirv
spv::Id delta = b.makeIntConstant((int)swizz[i] - (int)SwizzleChannel::C_X);
spv::Id delta = b.makeIntConstant(static_cast<int>(swizz[i]) - static_cast<int>(SwizzleChannel::C_X));
spv::Id access_offset = b.createBinOp(spv::OpIAdd, i32, offset, delta);
access_offset = b.createBinOp(spv::OpBitwiseAnd, i32, access_offset, b.makeIntConstant(3));

spv::Id first_base = b.createOp(spv::OpVectorExtractDynamic, target_type, { first, access_offset });
spv::Id second_base = b.createOp(spv::OpVectorExtractDynamic, target_type, { second, access_offset });
// select one if (int)swizz[i] - (int)SwizzleChannel::C_X < 4 - offset % 4
// select one if static_cast<int>(swizz[i]) - static_cast<int>(SwizzleChannel::C_X) < 4 - offset % 4
spv::Id cond = b.createBinOp(spv::OpSLessThan, b.makeBoolType(), delta, first_base_threshold);
ops.push_back(b.createOp(spv::OpSelect, target_type, { cond, first_base, second_base }));
}
Expand Down Expand Up @@ -956,7 +956,7 @@ spv::Id load(spv::Builder &b, const SpirvShaderParameters &params, SpirvUtilFunc
if (op.bank == RegisterBank::IMMEDIATE || !get_reg_bank(params, op.bank)) {
if (op.bank != RegisterBank::INDEXED1 && op.bank != RegisterBank::INDEXED2) {
if (dest_comp_count == 1) {
if ((int)op.swizzle[0] >= (int)SwizzleChannel::C_0) {
if (static_cast<int>(op.swizzle[0]) >= static_cast<int>(SwizzleChannel::C_0)) {
return get_correspond_constant_with_channel(b, op.swizzle[0]);
}
}
Expand Down Expand Up @@ -995,7 +995,7 @@ spv::Id load(spv::Builder &b, const SpirvShaderParameters &params, SpirvUtilFunc
const Imm2 bank_enc = (op.num >> 5) & 0b11;
const Imm5 add_off = (op.num & 0b11111) + shift_offset;

const std::int8_t idx_off = (int)op.bank - (int)RegisterBank::INDEXED1;
const std::int8_t idx_off = static_cast<int>(op.bank) - static_cast<int>(RegisterBank::INDEXED1);

switch (bank_enc) {
case 0: {
Expand Down Expand Up @@ -1293,7 +1293,7 @@ void store(spv::Builder &b, const SpirvShaderParameters &params, SpirvUtilFuncti
if (b.isScalar(source) || total_comp_source == 1) {
ops.push_back(source);
} else {
ops.push_back(b.createOp(spv::OpVectorExtractDynamic, vec_comp_type, { source, b.makeIntConstant(std::min(source_value_taken_count++, (int)total_comp_source - 1)) }));
ops.push_back(b.createOp(spv::OpVectorExtractDynamic, vec_comp_type, { source, b.makeIntConstant(std::min(source_value_taken_count++, static_cast<int>(total_comp_source) - 1)) }));
}
} else {
if (elem == spv::NoResult) {
Expand All @@ -1310,7 +1310,7 @@ void store(spv::Builder &b, const SpirvShaderParameters &params, SpirvUtilFuncti
}
}

spv::Id result_type = utils::make_vector_or_scalar_type(b, vec_comp_type, (int)ops.size());
spv::Id result_type = utils::make_vector_or_scalar_type(b, vec_comp_type, static_cast<int>(ops.size()));
spv::Id result = ops.size() == 1 ? ops[0] : b.createCompositeConstruct(result_type, ops);
result = pack_one(b, utils, features, result, dest.type);

Expand All @@ -1337,7 +1337,7 @@ void store(spv::Builder &b, const SpirvShaderParameters &params, SpirvUtilFuncti

// Now we do store!
if (total_comp_source == 1) {
insert_offset += (int)(nearest_swizz_on / (4 / size_comp));
insert_offset += static_cast<int>(nearest_swizz_on / (4 / size_comp));
elem = b.createOp(spv::OpAccessChain, comp_type, { bank_base, b.makeIntConstant(insert_offset >> 2) });
spv::Id inserted = b.createOp(spv::OpVectorInsertDynamic, bank_base_elem_type, { b.createLoad(elem, spv::NoPrecision), source, b.makeIntConstant(insert_offset % 4) });

Expand Down

0 comments on commit 8801e7f

Please sign in to comment.