From 00a19403fcd3c837024f9d97d4d6454f0b045965 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Sun, 18 Oct 2020 19:57:12 +0200 Subject: [PATCH] [misc] Solve some warning I don't know if it was really a good thing or if it's a starting point, but I did it anyway. --- .gitignore | 3 +++ configure.ac | 1 + libaegisub/audio/provider_convert.cpp | 11 +++++++---- libaegisub/include/libaegisub/util_osx.h | 2 +- libaegisub/unix/util.cpp | 4 ---- src/audio_player_oss.cpp | 2 +- src/audio_timing_karaoke.cpp | 7 ++++--- src/auto4_lua.cpp | 6 ++++-- src/auto4_lua_assfile.cpp | 2 +- src/dialog_version_check.cpp | 8 ++++---- src/gl/glext.h | 3 +++ src/hotkey.cpp | 5 ----- src/main.cpp | 3 ++- src/retina_helper.h | 2 -- src/video_display.cpp | 5 ++++- 15 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index d800491d4..1423a63c6 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,6 @@ vendor/luajit/src/luajit .nuget .vs +*.tmp +cscope.files +tags diff --git a/configure.ac b/configure.ac index d366fbfad..7163ab56d 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,7 @@ AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADER([acconf.h]) AC_GNU_SOURCE AC_CANONICAL_HOST +AM_SILENT_RULES([yes]) ########################### # Check host architecture diff --git a/libaegisub/audio/provider_convert.cpp b/libaegisub/audio/provider_convert.cpp index b45d8a852..d76728893 100644 --- a/libaegisub/audio/provider_convert.cpp +++ b/libaegisub/audio/provider_convert.cpp @@ -40,15 +40,16 @@ public: } void FillBuffer(void *buf, int64_t start, int64_t count64) const override { + if (count64 < 0) + abort(); // Convertion is not safe auto count = static_cast<size_t>(count64); - assert(count == count64); src_buf.resize(count * src_bytes_per_sample * channels); source->GetAudio(src_buf.data(), start, count); auto dest = static_cast<int16_t*>(buf); - for (int64_t i = 0; i < count * channels; ++i) { + for (int64_t i = 0; i < static_cast<int64_t>(count) * channels; ++i) { int64_t sample = 0; // 8 bits per sample is assumed to be unsigned with a bias of 127, @@ -84,8 +85,9 @@ public: } void FillBuffer(void *buf, int64_t start, int64_t count64) const override { + if (count64 < 0) + abort(); // Convertion is not safe auto count = static_cast<size_t>(count64); - assert(count == count64); src_buf.resize(count * channels); source->GetAudio(&src_buf[0], start, count); @@ -118,8 +120,9 @@ public: } void FillBuffer(void *buf, int64_t start, int64_t count64) const override { + if (count64 < 0) + abort(); // Convertion is not safe auto count = static_cast<size_t>(count64); - assert(count == count64); src_buf.resize(count * src_channels); source->GetAudio(&src_buf[0], start, count); diff --git a/libaegisub/include/libaegisub/util_osx.h b/libaegisub/include/libaegisub/util_osx.h index 3e4ce599e..9c839e181 100644 --- a/libaegisub/include/libaegisub/util_osx.h +++ b/libaegisub/include/libaegisub/util_osx.h @@ -33,7 +33,7 @@ namespace agi { namespace osx { class AppNapDisabler { - void *handle; + __attribute__((unused)) void *handle; public: AppNapDisabler(std::string reason); ~AppNapDisabler(); diff --git a/libaegisub/unix/util.cpp b/libaegisub/unix/util.cpp index 4cf672119..7a88bfecb 100644 --- a/libaegisub/unix/util.cpp +++ b/libaegisub/unix/util.cpp @@ -26,11 +26,7 @@ namespace agi { namespace util { void SetThreadName(const char *) { } void sleep_for(int ms) { -#ifdef __clang__ - std::this_thread::sleep_for(std::chrono::milliseconds(ms)); -#else boost::this_thread::sleep_for(boost::chrono::milliseconds(ms)); -#endif } } } diff --git a/src/audio_player_oss.cpp b/src/audio_player_oss.cpp index 93950baef..2d7abd560 100644 --- a/src/audio_player_oss.cpp +++ b/src/audio_player_oss.cpp @@ -267,7 +267,7 @@ int64_t OSSPlayer::GetCurrentPosition() LOG_D("player/audio/oss") << "cur_frame: " << cur_frame << " delay " << delay; // delay can jitter a bit at the end, detect that - if (cur_frame == end_frame && delay < rate / 20) { + if (cur_frame == end_frame && delay < static_cast<int>(rate / 20)) { return cur_frame; } return MAX(0, (long) cur_frame - delay); diff --git a/src/audio_timing_karaoke.cpp b/src/audio_timing_karaoke.cpp index 932d11250..5476b8ce0 100644 --- a/src/audio_timing_karaoke.cpp +++ b/src/audio_timing_karaoke.cpp @@ -562,10 +562,11 @@ void AudioTimingControllerKaraoke::OnMarkerDrag(std::vector<AudioMarker*> const& // Fix rounding error new_position = (new_position + 5) / 10 * 10; int old_position = m[0]->GetPosition(); - int syl = MoveMarker(static_cast<KaraokeMarker *>(m[0]), new_position); - if (syl < 0) return; + int syl_int = MoveMarker(static_cast<KaraokeMarker *>(m[0]), new_position); + if (syl_int < 0) return; + size_t syl = syl_int; - bool announce_primary = (syl == cur_syl || syl == cur_syl + 1); + bool announce_primary = ((syl == cur_syl) || (syl == (cur_syl + 1))); if (m.size() > 1) { int delta = m[0]->GetPosition() - old_position; for (AudioMarker *marker : m | boost::adaptors::sliced(1, m.size())) diff --git a/src/auto4_lua.cpp b/src/auto4_lua.cpp index 6c131902e..59c1e10af 100644 --- a/src/auto4_lua.cpp +++ b/src/auto4_lua.cpp @@ -244,7 +244,8 @@ namespace { lua_pushvalue(L, 1); std::unique_ptr<AssEntry> et(Automation4::LuaAssFile::LuaToAssEntry(L)); lua_pop(L, 1); - if (typeid(*et) != typeid(AssStyle)) + auto& et_ref = *et; + if (typeid(et_ref) != typeid(AssStyle)) return error(L, "Not a style entry"); double width, height, descent, extlead; @@ -840,7 +841,8 @@ namespace { throw LuaForEachBreak(); } - if (typeid(*lines[cur - 1]) != typeid(AssDialogue)) { + auto &prev_line = lines[cur - 1][0]; + if (typeid(prev_line) != typeid(AssDialogue)) { wxLogError("Selected row %d is not a dialogue line", cur); throw LuaForEachBreak(); } diff --git a/src/auto4_lua_assfile.cpp b/src/auto4_lua_assfile.cpp index 3aef3b769..91e66d932 100644 --- a/src/auto4_lua_assfile.cpp +++ b/src/auto4_lua_assfile.cpp @@ -744,7 +744,7 @@ namespace Automation4 { , can_modify(can_modify) , can_set_undo(can_set_undo) { - for (auto& line : ass->Info) + for (size_t i = 0; i < ass->Info.size(); ++i) lines.push_back(nullptr); for (auto& line : ass->Styles) lines.push_back(&line); diff --git a/src/dialog_version_check.cpp b/src/dialog_version_check.cpp index dcf2109cd..eaf2f0666 100644 --- a/src/dialog_version_check.cpp +++ b/src/dialog_version_check.cpp @@ -232,7 +232,7 @@ void PostErrorEvent(bool interactive, wxString const& error_text) { } } -static const char * GetOSShortName() { +__attribute__((unused)) static const char * GetOSShortName() { int osver_maj, osver_min; wxOperatingSystemId osid = wxGetOsVersion(&osver_maj, &osver_min); @@ -310,7 +310,7 @@ static wxString GetUILanguage() { return &output[0]; } -static wxString GetSystemLanguage() { +__attribute__((unused)) static wxString GetSystemLanguage() { wxString res = GetUILanguage(); if (!res) // On an old version of Windows, let's just return the LANGID as a string @@ -331,12 +331,12 @@ static wxString GetSystemLanguage() { } #else -static wxString GetSystemLanguage() { +__attribute__((unused)) static wxString GetSystemLanguage() { return wxLocale::GetLanguageInfo(wxLocale::GetSystemLanguage())->CanonicalName; } #endif -static wxString GetAegisubLanguage() { +__attribute__((unused)) static wxString GetAegisubLanguage() { return to_wx(OPT_GET("App/Language")->GetString()); } diff --git a/src/gl/glext.h b/src/gl/glext.h index cfb61d8cd..4f5e87f8b 100644 --- a/src/gl/glext.h +++ b/src/gl/glext.h @@ -31,6 +31,9 @@ extern "C" { /* Header file version number, required by OpenGL ABI for Linux */ /* glext.h last updated $Date: 2010-05-17 09:47:20 -0700 (Mon, 17 May 2010) $ */ /* Current version at http://www.opengl.org/registry/ */ +#ifdef GL_GLEXT_VERSION +#undef GL_GLEXT_VERSION +#endif #define GL_GLEXT_VERSION 62 /* Function declaration macros - to move into glplatform.h */ diff --git a/src/hotkey.cpp b/src/hotkey.cpp index c80d4fe67..45cbcdeb5 100644 --- a/src/hotkey.cpp +++ b/src/hotkey.cpp @@ -47,11 +47,6 @@ namespace { {nullptr} }; - const char *added_hotkeys_minimize[][3] = { - {"app/minimize", "Default", "Ctrl-M"}, - {nullptr} - }; - const char *added_hotkeys_time_tap[][3] = { {"time/tap/connect", "Audio", "I"}, {"time/tap/no_connect", "Audio", "O"}, diff --git a/src/main.cpp b/src/main.cpp index 7f6d9162c..801a3eec8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -148,7 +148,8 @@ bool AegisubApp::OnInit() { boost::filesystem::path::imbue(std::locale()); // Pointless `this` capture required due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494 - agi::dispatch::Init([this](agi::dispatch::Thunk f) { + // Because GCC 4.8 is VEARY OLD, the pointless capture as been removed... + agi::dispatch::Init([](agi::dispatch::Thunk f) { auto evt = new ValueEvent<agi::dispatch::Thunk>(EVT_CALL_THUNK, -1, std::move(f)); wxTheApp->QueueEvent(evt); }); diff --git a/src/retina_helper.h b/src/retina_helper.h index ec4111955..389036d0f 100644 --- a/src/retina_helper.h +++ b/src/retina_helper.h @@ -19,8 +19,6 @@ class wxWindow; class RetinaHelper { - wxWindow *window; - void *observer; agi::signal::Signal<int> ScaleFactorChanged; public: RetinaHelper(wxWindow *window); diff --git a/src/video_display.cpp b/src/video_display.cpp index 2df9ec3c0..ef8bed67b 100644 --- a/src/video_display.cpp +++ b/src/video_display.cpp @@ -428,7 +428,10 @@ void VideoDisplay::SetTool(std::unique_ptr<VisualToolBase> new_tool) { } bool VideoDisplay::ToolIsType(std::type_info const& type) const { - return tool && typeid(*tool) == type; + if (! tool) + return false; + auto &tool_type = *tool; + return typeid(tool_type) == type; } Vector2D VideoDisplay::GetMousePosition() const { -- GitLab