Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Warn #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 9 additions & 9 deletions vita3k/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) {
large_font_config.SizePixels = 116.f;
gui.large_font = io.Fonts->AddFontFromFileTTF(fs_utils::path_to_utf8(latin_fw_font_path).c_str(), large_font_config.SizePixels, &large_font_config, large_font_chars);
} else {
LOG_WARN("Could not find firmware font file at \"{}\", install firmware fonts package to fix this.", latin_fw_font_path);
LOG_WARN("Could not find firmware font file at {}, install firmware fonts package to fix this.", latin_fw_font_path);
font_config.SizePixels = 22.f;

// Set up default font path
Expand All @@ -261,7 +261,7 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) {

LOG_INFO("Using default Vita3K font.");
} else
LOG_WARN("Could not find default Vita3K font at \"{}\", using default ImGui font.", default_font_path);
LOG_WARN("Could not find default Vita3K font at {}, using default ImGui font.", default_font_path);
}

// Build font atlas loaded and upload to GPU
Expand Down Expand Up @@ -423,18 +423,18 @@ static bool get_user_apps(GuiState &gui, EmuEnvState &emuenv) {
gui.app_selector.user_apps.clear();
// Read size of apps list
size_t size;
apps_cache.read((char *)&size, sizeof(size));
apps_cache.read(reinterpret_cast<char *>(&size), sizeof(size));

// Check version of cache
uint32_t versionInFile;
apps_cache.read((char *)&versionInFile, sizeof(uint32_t));
apps_cache.read(reinterpret_cast<char *>(&versionInFile), sizeof(uint32_t));
if (versionInFile != 1) {
LOG_WARN("Current version of cache: {}, is outdated, recreate it.", versionInFile);
return false;
}

// Read language of cache
apps_cache.read((char *)&gui.app_selector.apps_cache_lang, sizeof(uint32_t));
apps_cache.read(reinterpret_cast<char *>(&gui.app_selector.apps_cache_lang), sizeof(uint32_t));
if (gui.app_selector.apps_cache_lang != emuenv.cfg.sys_lang) {
LOG_WARN("Current lang of cache: {}, is different configuration: {}, recreate it.", get_sys_lang_name(gui.app_selector.apps_cache_lang), get_sys_lang_name(emuenv.cfg.sys_lang));
return false;
Expand All @@ -445,7 +445,7 @@ static bool get_user_apps(GuiState &gui, EmuEnvState &emuenv) {
auto read = [&apps_cache]() {
size_t size;

apps_cache.read((char *)&size, sizeof(size));
apps_cache.read(reinterpret_cast<char *>(&size), sizeof(size));

std::vector<char> buffer(size); // dont trust std::string to hold buffer enough
apps_cache.read(buffer.data(), size);
Expand Down Expand Up @@ -488,18 +488,18 @@ void save_apps_cache(GuiState &gui, EmuEnvState &emuenv) {

// Write version of cache
const uint32_t versionInFile = 1;
apps_cache.write((const char *)&versionInFile, sizeof(uint32_t));
apps_cache.write(reinterpret_cast<const char *>(&versionInFile), sizeof(uint32_t));

// Write language of cache
gui.app_selector.apps_cache_lang = emuenv.cfg.sys_lang;
apps_cache.write((char *)&gui.app_selector.apps_cache_lang, sizeof(uint32_t));
apps_cache.write(reinterpret_cast<char *>(&gui.app_selector.apps_cache_lang), sizeof(uint32_t));

// Write Apps list
for (const App &app : gui.app_selector.user_apps) {
auto write = [&apps_cache](const std::string &i) {
const auto size = i.length();

apps_cache.write((const char *)&size, sizeof(size));
apps_cache.write(reinterpret_cast<const char *>(&size), sizeof(size));
apps_cache.write(i.c_str(), size);
};

Expand Down
14 changes: 7 additions & 7 deletions vita3k/gui/src/imgui_impl_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ IMGUI_API ImGui_State *ImGui_ImplSdl_Init(renderer::State *renderer, SDL_Window
// Set platform dependent data in viewport
// Our mouse update function expect PlatformHandle to be filled for the main viewport
ImGuiViewport *main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = (void *)window;
main_viewport->PlatformHandle = static_cast<void *>(window);
main_viewport->PlatformHandleRaw = nullptr;
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(window, &info)) {
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
main_viewport->PlatformHandleRaw = (void *)info.info.win.window;
main_viewport->PlatformHandleRaw = static_cast<void *>(info.info.win.window);
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
main_viewport->PlatformHandleRaw = (void *)info.info.cocoa.window;
main_viewport->PlatformHandleRaw = static_cast<void *>(info.info.cocoa.window);
#endif
}

Expand Down Expand Up @@ -137,13 +137,13 @@ IMGUI_API void ImGui_ImplSdl_NewFrame(ImGui_State *state) {
int display_w, display_h;
SDL_GetWindowSize(state->window, &w, &h);
ImGui_ImplSdl_GetDrawableSize(state, display_w, display_h);
io.DisplaySize = ImVec2((float)w, (float)h);
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
io.DisplaySize = ImVec2(static_cast<float>(w), static_cast<float>(h));
io.DisplayFramebufferScale = ImVec2(w > 0 ? (static_cast<float>(display_w) / w) : 0, h > 0 ? (static_cast<float>(display_h) / h) : 0);

// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
static Uint64 frequency = SDL_GetPerformanceFrequency();
Uint64 current_time = SDL_GetPerformanceCounter();
io.DeltaTime = state->time > 0 ? (float)((double)(current_time - state->time) / frequency) : (1.0f / 60.0f);
io.DeltaTime = state->time > 0 ? static_cast<float>(static_cast<double>(current_time - state->time) / frequency) : (1.0f / 60.0f);
state->time = current_time;

// Setup mouse inputs (we already got mouse wheel, keyboard keys & characters from our event handler)
Expand All @@ -156,7 +156,7 @@ IMGUI_API void ImGui_ImplSdl_NewFrame(ImGui_State *state) {
state->mouse_pressed[0] = state->mouse_pressed[1] = state->mouse_pressed[2] = false;

if ((SDL_GetWindowFlags(state->window) & SDL_WINDOW_INPUT_FOCUS) != 0)
io.MousePos = ImVec2((float)mx, (float)my);
io.MousePos = ImVec2(static_cast<float>(mx), static_cast<float>(my));

// Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) == 0) {
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
2 changes: 1 addition & 1 deletion vita3k/modules/SceNet/SceNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ EXPORT(int, sceNetResolverGetError) {

EXPORT(int, sceNetResolverStartAton, int rid, const SceNetInAddr *addr, char *hostname, int len, int timeout, int retry, int flags) {
TRACY_FUNC(sceNetResolverStartAton, rid, addr, hostname, len, timeout, retry, flags);
struct hostent *resolved = gethostbyaddr((const char *)addr, len, AF_INET);
struct hostent *resolved = gethostbyaddr(reinterpret_cast<const char *>(addr), len, AF_INET);
strcpy(hostname, resolved->h_name);
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions vita3k/net/src/posixsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ int PosixSocket::get_socket_options(int level, int optname, void *optval, unsign
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_USECRYPTO, sockopt_so_usecrypto);
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_USESIGNATURE, sockopt_so_usesignature);
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_TPPOLICY, sockopt_so_tppolicy);
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_NAME, (char)0); // writes an empty string to the output buffer
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_NAME, static_cast<char>(0)); // writes an empty string to the output buffer
}
} else if (level == IPPROTO_IP) {
switch (optname) {
Expand Down Expand Up @@ -346,22 +346,22 @@ int PosixSocket::get_socket_options(int level, int optname, void *optval, unsign
int PosixSocket::recv_packet(void *buf, unsigned int len, int flags, SceNetSockaddr *from, unsigned int *fromlen) {
if (from != nullptr) {
sockaddr addr;
int res = recvfrom(sock, (char *)buf, len, flags, &addr, (socklen_t *)fromlen);
int res = recvfrom(sock, static_cast<char *>(buf), len, flags, &addr, (socklen_t *)fromlen);
convertPosixSockaddrToSce(&addr, from);
*fromlen = sizeof(SceNetSockaddrIn);

return translate_return_value(res);
} else {
return translate_return_value(recv(sock, (char *)buf, len, flags));
return translate_return_value(recv(sock, static_cast<char *>(buf), len, flags));
}
}

int PosixSocket::send_packet(const void *msg, unsigned int len, int flags, const SceNetSockaddr *to, unsigned int tolen) {
if (to != nullptr) {
sockaddr addr;
convertSceSockaddrToPosix(to, &addr);
return translate_return_value(sendto(sock, (const char *)msg, len, flags, &addr, sizeof(sockaddr_in)));
return translate_return_value(sendto(sock, static_cast<const char *>(msg), len, flags, &addr, sizeof(sockaddr_in)));
} else {
return translate_return_value(send(sock, (const char *)msg, len, flags));
return translate_return_value(send(sock, static_cast<const char *>(msg), len, flags));
}
}
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
2 changes: 1 addition & 1 deletion vita3k/packages/src/license.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static bool open_license(const fs::path &license_path, SceNpDrmLicense &license_
memset(&license_buf, 0, sizeof(SceNpDrmLicense));
fs::ifstream license(license_path, std::ios::in | std::ios::binary);
if (license.is_open()) {
license.read((char *)&license_buf, sizeof(SceNpDrmLicense));
license.read(reinterpret_cast<char *>(&license_buf), sizeof(SceNpDrmLicense));
license.close();
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions vita3k/packages/src/pkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool install_pkg(const fs::path &pkg_path, EmuEnvState &emuenv, std::string &p_z
for (uint32_t i = 0; i < byte_swap(pkg_header.info_count); i++) {
uint32_t block[4];
infile.seekg(info_offset);
infile.read((char *)block, sizeof(block));
infile.read(reinterpret_cast<char *>(block), sizeof(block));

auto type = byte_swap(block[0]);
auto size = byte_swap(block[1]);
Expand Down Expand Up @@ -202,7 +202,7 @@ bool install_pkg(const fs::path &pkg_path, EmuEnvState &emuenv, std::string &p_z
std::vector<uint8_t> sfo_buffer(sfo_size);
SfoFile sfo_file;
infile.seekg(sfo_offset);
infile.read((char *)&sfo_buffer[0], sfo_size);
infile.read(reinterpret_cast<char *>(&sfo_buffer[0]), sfo_size);
sfo::load(sfo_file, sfo_buffer);
sfo::get_param_info(emuenv.app_info, sfo_buffer, emuenv.cfg.sys_lang);

Expand Down Expand Up @@ -259,11 +259,11 @@ bool install_pkg(const fs::path &pkg_path, EmuEnvState &emuenv, std::string &p_z
evp_cleanup();
return false;
}
const auto file_count = (float)byte_swap(pkg_header.file_count);
const auto file_count = static_cast<float>(byte_swap(pkg_header.file_count));
progress_callback(i / file_count * 100.f * 0.6f);
std::vector<unsigned char> name(byte_swap(entry.name_size));
infile.seekg(byte_swap(pkg_header.data_offset) + byte_swap(entry.name_offset));
infile.read((char *)&name[0], byte_swap(entry.name_size));
infile.read(reinterpret_cast<char *>(&name[0]), byte_swap(entry.name_size));

decrypt_aes_ctr(byte_swap(entry.name_offset) / 16, name.data(), byte_swap(entry.name_size));

Expand Down
Loading
Loading