fix goalc crash and clang warnings (#1441)

This commit is contained in:
water111 2022-06-11 16:52:27 -04:00 committed by GitHub
parent 7c5c7003b3
commit 7bf19759d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 25 deletions

View file

@ -146,7 +146,7 @@ int set_socket_timeout(int socket, long microSeconds) {
int write_to_socket(int socket, const char* buf, int len) {
int bytes_wrote = 0;
#ifdef __linux
bytes_wrote = write(socket, buf, len);
bytes_wrote = send(socket, buf, len, MSG_NOSIGNAL);
#elif _WIN32
bytes_wrote = send(socket, buf, len, 0);
#endif

View file

@ -92,7 +92,7 @@ class GameSubtitleSceneInfo {
std::string speaker_utf8;
bool offscreen;
bool operator<(const SubtitleLine& line) const { return (frame < line.frame); }
bool operator<(const SubtitleLine& other) const { return (frame < other.frame); }
};
GameSubtitleSceneInfo() {}

View file

@ -456,7 +456,7 @@ FormElement* rewrite_as_send_event(LetElement* in,
{Matcher::any(0), Matcher::reg(block_var_reg)});
auto mr_with_shell = rewrite_shelled_return_form(
call_matcher, body->at(3 + param_count), env, pool,
[&](FormElement* s_in, const MatchResult& mr, const Env& env, FormPool& pool) {
[&](FormElement* /*s_in*/, const MatchResult& mr, const Env& /*env*/, FormPool& pool) {
Form* send_destination = mr.maps.forms.at(0);
// time to build the macro!
@ -1306,7 +1306,7 @@ FormElement* rewrite_proc_new(LetElement* in, const Env& env, FormPool& pool) {
{Matcher::reg(ra.reg()), Matcher::any(1)}),
Matcher::any(2)})),
macro_form, env, pool,
[&](FormElement* s_in, const MatchResult& mr, const Env& env, FormPool& pool) {
[&](FormElement* s_in, const MatchResult& /*mr*/, const Env& env, FormPool& pool) {
auto as_when = dynamic_cast<CondNoElseElement*>(s_in);
const auto& when_body = as_when->entries.front().body->elts();
@ -1382,7 +1382,7 @@ FormElement* rewrite_proc_new(LetElement* in, const Env& env, FormPool& pool) {
// args
// this would be a great place to do some hacky stuff! hmm, maybe i will...
for (int i = 2; i < as_func->elts().size(); ++i) {
for (size_t i = 2; i < as_func->elts().size(); ++i) {
args.push_back(as_func->elts().at(i));
}
@ -1541,7 +1541,7 @@ FormElement* rewrite_attack_info(LetElement* in, const Env& env, FormPool& pool)
// (static-attack-info :mask <mask> etc)
auto mr_with_shell = rewrite_shelled_return_form(
Matcher::reg(block_var_reg), in->body()->at(in->body()->size() - 1), env, pool,
[&](FormElement* s_in, const MatchResult& mr, const Env& env, FormPool& pool) {
[&](FormElement* /*s_in*/, const MatchResult& /*mr*/, const Env& env, FormPool& pool) {
// time to build the macro!
std::vector<Form*> macro_args;
@ -1733,7 +1733,7 @@ FormElement* rewrite_rand_float_gen(LetElement* in, const Env& env, FormPool& po
} else {
auto mr_res = rewrite_shelled_return_form(
matcher_res, in->body()->at(0), env, pool,
[&](FormElement* s_in, const MatchResult& mr, const Env& env, FormPool& pool) {
[&](FormElement* /*s_in*/, const MatchResult& /*mr*/, const Env& /*env*/, FormPool& pool) {
auto head =
GenericOperator::make_function(pool.form<ConstantTokenElement>("rand-float-gen"));
return gen ? pool.form<GenericElement>(head, gen) : pool.form<GenericElement>(head);

View file

@ -252,7 +252,7 @@ void render_game_frame(int width, int height, int lbox_width, int lbox_height) {
if (options.save_screenshot) {
// ensure the screenshot has an extension
std::string temp_path = g_gfx_data->debug_gui.screenshot_name();
if (endsWith(temp_path, ".png")) {
if (!endsWith(temp_path, ".png")) {
temp_path += ".png";
}
options.screenshot_path = make_output_file_name(temp_path);

View file

@ -109,10 +109,10 @@ bool IOP_Kernel::OnlyThreadAlive(s32 thid) {
bool yes = false;
for (u64 i = 0; i < threads.size(); i++) {
if (threads[i].started && !threads[i].done) {
if (i != thid) {
if ((s32)i != thid) {
return false;
}
if (i == thid) {
if ((s32)i == thid) {
yes = true;
}
}

View file

@ -282,7 +282,7 @@ void SubtitleEditor::draw_all_scenes(std::string group_name, bool base_cutscenes
if (ImGui::TreeNode(
fmt::format("{}-{}", scene_name, base_cutscenes ? m_base_language : m_current_language)
.c_str(),
scene_name.c_str())) {
"%s", scene_name.c_str())) {
if (base_cutscenes || is_current_scene) {
ImGui::PopStyleColor();
}
@ -313,8 +313,8 @@ void SubtitleEditor::draw_all_scenes(std::string group_name, bool base_cutscenes
ImGui::NewLine();
}
if (ImGui::BeginCombo("Sorting Group", scene_info.m_sorting_group.c_str())) {
for (int i = 0; i < m_subtitle_db.m_subtitle_groups->m_group_order.size(); ++i) {
const bool isSelected = (scene_info.m_sorting_group_idx == i);
for (size_t i = 0; i < m_subtitle_db.m_subtitle_groups->m_group_order.size(); ++i) {
const bool isSelected = (scene_info.m_sorting_group_idx == (int)i);
if (ImGui::Selectable(m_subtitle_db.m_subtitle_groups->m_group_order[i].c_str(),
isSelected)) {
// Remove from current group
@ -332,7 +332,7 @@ void SubtitleEditor::draw_all_scenes(std::string group_name, bool base_cutscenes
}
ImGui::EndCombo();
}
for (int i = 0; i < scene_info.m_lines.size(); i++) {
for (size_t i = 0; i < scene_info.m_lines.size(); i++) {
auto& subtitleLine = scene_info.m_lines.at(i);
std::string summary;
if (subtitleLine.line_utf8.empty()) {
@ -346,7 +346,7 @@ void SubtitleEditor::draw_all_scenes(std::string group_name, bool base_cutscenes
} else if (subtitleLine.offscreen) {
ImGui::PushStyleColor(ImGuiCol_Text, m_offscreen_text_color);
}
if (ImGui::TreeNode(fmt::format("{}", i).c_str(), summary.c_str())) {
if (ImGui::TreeNode(fmt::format("{}", i).c_str(), "%s", summary.c_str())) {
if (subtitleLine.line_utf8.empty() || subtitleLine.offscreen) {
ImGui::PopStyleColor();
}
@ -400,8 +400,8 @@ void SubtitleEditor::draw_current_cutscene() {
ImGui::NewLine();
}
if (ImGui::BeginCombo("Sorting Group", m_current_scene->m_sorting_group.c_str())) {
for (int i = 0; i < m_subtitle_db.m_subtitle_groups->m_group_order.size(); ++i) {
const bool isSelected = (m_current_scene->m_sorting_group_idx == i);
for (size_t i = 0; i < m_subtitle_db.m_subtitle_groups->m_group_order.size(); ++i) {
const bool isSelected = (m_current_scene->m_sorting_group_idx == (int)i);
if (ImGui::Selectable(m_subtitle_db.m_subtitle_groups->m_group_order[i].c_str(),
isSelected)) {
// Remove from current group
@ -452,7 +452,7 @@ void SubtitleEditor::draw_current_cutscene() {
}
}
ImGui::NewLine();
for (int i = 0; i < m_current_scene->m_lines.size(); i++) {
for (size_t i = 0; i < m_current_scene->m_lines.size(); i++) {
auto& subtitleLine = m_current_scene->m_lines.at(i);
std::string summary;
if (subtitleLine.line_utf8.empty()) {
@ -466,7 +466,7 @@ void SubtitleEditor::draw_current_cutscene() {
} else if (subtitleLine.offscreen) {
ImGui::PushStyleColor(ImGuiCol_Text, m_offscreen_text_color);
}
if (ImGui::TreeNode(fmt::format("{}", i).c_str(), summary.c_str())) {
if (ImGui::TreeNode(fmt::format("{}", i).c_str(), "%s", summary.c_str())) {
if (subtitleLine.line_utf8.empty() || subtitleLine.offscreen) {
ImGui::PopStyleColor();
}

12
third-party/imgui/imgui_stdlib.cpp generated vendored
View file

@ -22,7 +22,7 @@ static int InputTextCallback(ImGuiInputTextCallbackData* data) {
std::string* str = user_data->Str;
IM_ASSERT(data->Buf == str->c_str());
str->resize(data->BufTextLen);
data->Buf = (char*)str->c_str();
data->Buf = str->data();
} else if (user_data->ChainCallback) {
// Forward to user callback, if any
data->UserData = user_data->ChainCallbackUserData;
@ -43,7 +43,7 @@ bool ImGui::InputText(const char* label,
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback,
return InputText(label, str->data(), str->capacity() + 1, flags, InputTextCallback,
&cb_user_data);
}
@ -60,8 +60,8 @@ bool ImGui::InputTextMultiline(const char* label,
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags,
InputTextCallback, &cb_user_data);
return InputTextMultiline(label, str->data(), str->capacity() + 1, size, flags, InputTextCallback,
&cb_user_data);
}
bool ImGui::InputTextWithHint(const char* label,
@ -77,6 +77,6 @@ bool ImGui::InputTextWithHint(const char* label,
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags,
InputTextCallback, &cb_user_data);
return InputTextWithHint(label, hint, str->data(), str->capacity() + 1, flags, InputTextCallback,
&cb_user_data);
}