Fix a bunch of compiler warnings

This commit is contained in:
Connor McLaughlin 2021-06-03 23:03:06 +10:00
parent 270bf59817
commit 350049826f
23 changed files with 41 additions and 39 deletions

View file

@ -7,6 +7,7 @@
#include "log.h"
#include <algorithm>
#include <cerrno>
#include <cinttypes>
#include <map>
Log_SetChannel(CDImageCueSheet);
@ -140,11 +141,11 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Common::Error* error)
file_size /= track_sector_size;
if (track_start >= file_size)
{
Log_ErrorPrintf("Failed to open track %u in '%s': track start is out of range (%ld vs %ld)", track_num,
Log_ErrorPrintf("Failed to open track %u in '%s': track start is out of range (%u vs %" PRIu64 ")", track_num,
filename, track_start, file_size);
if (error)
{
error->SetFormattedMessage("Failed to open track %u in '%s': track start is out of range (%ld vs %ld)",
error->SetFormattedMessage("Failed to open track %u in '%s': track start is out of range (%u vs %" PRIu64 ")",
track_num, filename, track_start, file_size);
}
return false;

View file

@ -40,7 +40,6 @@ static constexpr std::array<u32, 256> ComputeEDCLUT()
std::array<u32, 256> edc_lut{};
for (u32 i = 0; i < 256; i++)
{
u32 j = (i << 1) ^ (i & 0x80 ? 0x11D : 0);
u32 edc = i;
for (u32 k = 0; k < 8; k++)
edc = (edc >> 1) ^ (edc & 1 ? 0xD8018001 : 0);
@ -252,7 +251,6 @@ bool CDImageEcm::Open(const char* filename, Common::Error* error)
for (;;)
{
long n = std::ftell(m_fp);
int bits = std::fgetc(m_fp);
if (bits == EOF)
{

View file

@ -98,7 +98,7 @@ static constexpr bool HostIsLittleEndian()
{
u8 a[4];
u32 b;
} test_val = {1};
} test_val = {{1}};
return test_val.a[0] == 1;
}

View file

@ -77,11 +77,11 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
m_indices = parent_image->GetIndices();
m_parent_image = std::move(parent_image);
if (magic == '3FPP')
if (magic == 0x33465050) // PPF3
return ReadV3Patch(fp.get());
else if (magic == '2FPP')
else if (magic == 0x32465050) // PPF2
return ReadV2Patch(fp.get());
else if (magic == '1FPP')
else if (magic == 0x31465050) // PPF1
return ReadV1Patch(fp.get());
Log_ErrorPrintf("Unknown PPF magic %08X", magic);
@ -99,7 +99,7 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
return 0;
}
if (magic != 'ZID.')
if (magic != 0x5A49442E) // .DIZ
return 0;
u32 dlen = 0;

View file

@ -120,8 +120,6 @@ std::string_view File::GetToken(const char*& line)
std::optional<MSF> File::GetMSF(const std::string_view& token)
{
const u32 len = static_cast<u32>(token.length());
static const s32 max_values[] = {std::numeric_limits<s32>::max(), 60, 75};
u32 parts[3] = {};
@ -190,7 +188,7 @@ bool File::ParseLine(const char* line, u32 line_number, Common::Error* error)
if (TokenMatch(command, "POSTGAP"))
{
Log_WarningPrintf("Ignoring '*%s' command", static_cast<int>(command.size()), command.data());
Log_WarningPrintf("Ignoring '%*s' command", static_cast<int>(command.size()), command.data());
return true;
}

View file

@ -221,7 +221,6 @@ static bool FindUriFiles(const char* path, const char* pattern, u32 flags, FindR
// small speed optimization for '*' case
bool hasWildCards = false;
bool wildCardMatchAll = false;
u32 nFiles = 0;
if (std::strpbrk(pattern, "*?") != nullptr)
{
hasWildCards = true;

View file

@ -1,7 +1,5 @@
#include "context_egl_wayland.h"
#include "../log.h"
#include <wayland-egl.h>
Log_SetChannel(GL::ContextEGLWayland);
namespace GL {
ContextEGLWayland::ContextEGLWayland(const WindowInfo& wi) : ContextEGL(wi) {}

View file

@ -143,6 +143,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable)
return false;
}
m_size = size;
m_writable = writable;
m_executable = executable;
return true;
#elif defined(__ANDROID__)
m_shmem_fd = AshmemCreateFileMapping(file_mapping_name.c_str(), size);
@ -152,6 +155,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable)
return false;
}
m_size = size;
m_writable = writable;
m_executable = executable;
return true;
#elif defined(__linux__)
m_shmem_fd = shm_open(file_mapping_name.c_str(), O_CREAT | O_EXCL | (writable ? O_RDWR : O_RDONLY), 0600);
@ -171,6 +177,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable)
return false;
}
m_size = size;
m_writable = writable;
m_executable = executable;
return true;
#elif defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__)
@ -197,6 +206,9 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable)
return false;
}
m_size = size;
m_writable = writable;
m_executable = executable;
return true;
#else
return false;

View file

@ -37,6 +37,10 @@ public:
static void* FindBaseAddressForMapping(size_t size);
ALWAYS_INLINE size_t GetSize() const { return m_size; }
ALWAYS_INLINE bool IsWritable() const { return m_writable; }
ALWAYS_INLINE bool IsExecutable() const { return m_executable; }
bool IsValid() const;
bool Create(size_t size, bool writable, bool executable);
void Destroy();

View file

@ -212,7 +212,7 @@ char* sjis2utf8(char* input)
// Simplify the input and decode standard ASCII characters
sjis2ascii(input);
int len = static_cast<int>(std::strlen(input));
size_t len = static_cast<int>(std::strlen(input));
char* output = reinterpret_cast<char*>(
std::malloc(3 * len)); // ShiftJis won't give 4byte UTF8, so max. 3 byte per input char are needed
size_t indexInput = 0, indexOutput = 0;

View file

@ -23,7 +23,6 @@ constexpr HostReg RARG2 = 1;
constexpr HostReg RARG3 = 2;
constexpr HostReg RARG4 = 3;
constexpr HostReg RSCRATCH = 12;
constexpr u32 FUNCTION_CALL_STACK_ALIGNMENT = 16;
constexpr u32 FUNCTION_CALL_SHADOW_SPACE = 32;
constexpr u32 FUNCTION_CALLEE_SAVED_SPACE_RESERVE = 80; // 8 registers
constexpr u32 FUNCTION_CALLER_SAVED_SPACE_RESERVE = 144; // 18 registers -> 224 bytes
@ -174,12 +173,14 @@ void CodeGenerator::EmitBeginBlock()
// Save the link register, since we'll be calling functions.
const bool link_reg_allocated = m_register_cache.AllocateHostReg(14);
DebugAssert(link_reg_allocated);
UNREFERENCED_VARIABLE(link_reg_allocated);
m_register_cache.AssumeCalleeSavedRegistersAreSaved();
// Store the CPU struct pointer. TODO: make this better.
const bool cpu_reg_allocated = m_register_cache.AllocateHostReg(RCPUPTR);
// m_emit->Mov(GetCPUPtrReg(), reinterpret_cast<uintptr_t>(&g_state));
DebugAssert(cpu_reg_allocated);
UNREFERENCED_VARIABLE(cpu_reg_allocated);
}
void CodeGenerator::EmitEndBlock()

View file

@ -21,7 +21,6 @@ constexpr HostReg RARG2 = 1;
constexpr HostReg RARG3 = 2;
constexpr HostReg RARG4 = 3;
constexpr HostReg RSCRATCH = 8;
constexpr u64 FUNCTION_CALL_STACK_ALIGNMENT = 16;
constexpr u64 FUNCTION_CALL_SHADOW_SPACE = 32;
constexpr u64 FUNCTION_CALLEE_SAVED_SPACE_RESERVE = 80; // 8 registers
constexpr u64 FUNCTION_CALLER_SAVED_SPACE_RESERVE = 144; // 18 registers -> 224 bytes

View file

@ -213,6 +213,7 @@ void CodeGenerator::EmitBeginBlock()
// Store the CPU struct pointer.
const bool cpu_reg_allocated = m_register_cache.AllocateHostReg(RCPUPTR);
DebugAssert(cpu_reg_allocated);
UNREFERENCED_VARIABLE(cpu_reg_allocated);
// m_emit->mov(GetCPUPtrReg(), reinterpret_cast<size_t>(&g_state));
// If there's loadstore instructions, preload the fastmem base.
@ -220,6 +221,7 @@ void CodeGenerator::EmitBeginBlock()
{
const bool fastmem_reg_allocated = m_register_cache.AllocateHostReg(RMEMBASEPTR);
Assert(fastmem_reg_allocated);
UNREFERENCED_VARIABLE(fastmem_reg_allocated);
m_emit->mov(GetFastmemBasePtrReg(), m_emit->qword[GetCPUPtrReg() + offsetof(CPU::State, fastmem_base)]);
}
}

View file

@ -334,7 +334,7 @@ void GPU_HW_OpenGL::SetCapabilities(HostDisplay* host_display)
GLint max_texel_buffer_size;
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, reinterpret_cast<GLint*>(&max_texel_buffer_size));
Log_InfoPrintf("Max texel buffer size: %u", max_texel_buffer_size);
if (max_texel_buffer_size < VRAM_WIDTH * VRAM_HEIGHT)
if (max_texel_buffer_size < static_cast<int>(VRAM_WIDTH * VRAM_HEIGHT))
{
Log_WarningPrintf("Maximum texture buffer size is less than VRAM size, not using texel buffers.");
m_use_texture_buffer_for_vram_writes = false;

View file

@ -293,8 +293,8 @@ u32 NeGcon::StaticGetVibrationMotorCount()
Controller::SettingList NeGcon::StaticGetSettings()
{
static constexpr std::array<SettingInfo, 1> settings = {
{SettingInfo::Type::Float, "SteeringDeadzone", TRANSLATABLE("NeGcon", "Steering Axis Deadzone"),
TRANSLATABLE("NeGcon", "Sets deadzone size for steering axis."), "0.00f", "0.00f", "0.99f", "0.01f"}};
{{SettingInfo::Type::Float, "SteeringDeadzone", TRANSLATABLE("NeGcon", "Steering Axis Deadzone"),
TRANSLATABLE("NeGcon", "Sets deadzone size for steering axis."), "0.00f", "0.00f", "0.99f", "0.01f"}}};
return SettingList(settings.begin(), settings.end());
}

View file

@ -82,8 +82,8 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
// dev-friendly untranslated console log.
Log_DevPrintf("Controller type mismatch in slot %u: state=%s(%u) ui=%s(%u) load_from_state=%s", i + 1u,
Settings::GetControllerTypeName(state_controller_type), state_controller_type,
Settings::GetControllerTypeName(controller_type), controller_type,
Settings::GetControllerTypeName(state_controller_type), static_cast<unsigned>(state_controller_type),
Settings::GetControllerTypeName(controller_type), static_cast<unsigned>(controller_type),
g_settings.load_devices_from_save_states ? "yes" : "no");
if (g_settings.load_devices_from_save_states)

View file

@ -212,10 +212,7 @@ double ALWAYS_INLINE_RELEASE f16Overflow(double in)
// pgxp_mem.c
static void PGXP_InitMem();
static const u32 UserMemOffset = 0;
static const u32 ScratchOffset = 2048 * 1024 / 4;
static const u32 RegisterOffset = 2 * 2048 * 1024 / 4;
static const u32 InvalidAddress = 3 * 2048 * 1024 / 4;
void PGXP_InitMem()
{

View file

@ -1906,9 +1906,6 @@ void UpdateMemoryCardTypes()
void UpdatePerGameMemoryCards()
{
// Disable memory cards when running PSFs.
const bool is_running_psf = !s_running_game_path.empty() && IsPsfFileName(s_running_game_path.c_str());
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
{
const MemoryCardType type = g_settings.memory_card_types[i];

View file

@ -258,13 +258,13 @@ static const std::map<int, const char*> s_evdev_key_names = {{KEY_ESC, "Escape"}
{KEY_RFKILL, "Rfkill"},
{KEY_MICMUTE, "Micmute"}};
static const char* GetKeyName(int key)
static inline const char* GetKeyName(int key)
{
const auto it = s_evdev_key_names.find(key);
return it == s_evdev_key_names.end() ? nullptr : it->second;
}
static std::optional<int> GetKeyCodeForName(const std::string_view key_name)
static inline std::optional<int> GetKeyCodeForName(const std::string_view key_name)
{
for (const auto& it : s_evdev_key_names)
{

View file

@ -57,7 +57,6 @@ AchievementSettingsWidget::~AchievementSettingsWidget() = default;
void AchievementSettingsWidget::updateEnableState()
{
const bool enabled = m_host_interface->GetBoolSettingValue("Cheevos", "Enabled", false);
const bool challenge_mode = m_host_interface->GetBoolSettingValue("Cheevos", "ChallengeMode", false);
m_ui.testMode->setEnabled(enabled);
m_ui.useFirstDiscFromPlaylist->setEnabled(enabled);
m_ui.richPresence->setEnabled(enabled);

View file

@ -57,7 +57,6 @@ ALWAYS_INLINE_RELEASE static void ResizeColumnsForView(T* view, const std::initi
header = view->header();
const int min_column_width = header->minimumSectionSize();
const int max_column_width = header->maximumSectionSize();
const int scrollbar_width = ((view->verticalScrollBar() && view->verticalScrollBar()->isVisible()) ||
view->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOn) ?
view->verticalScrollBar()->width() :

View file

@ -1098,7 +1098,6 @@ void CommonHostInterface::DrawFPSWindow()
position_y += text_size.y + spacing; \
} while (0)
const System::State state = System::GetState();
if (System::GetState() == System::State::Running)
{
const float speed = System::GetEmulationSpeed();
@ -2015,7 +2014,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
});
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ChangeDisc"),
StaticString(TRANSLATABLE("Hotkeys", "Change Disc")), [this](bool pressed) {
StaticString(TRANSLATABLE("Hotkeys", "Change Disc")), [](bool pressed) {
if (pressed && System::IsValid() && System::HasMediaSubImages())
{
const u32 current = System::GetMediaSubImageIndex();
@ -2887,7 +2886,6 @@ void CommonHostInterface::LoadSettings(SettingsInterface& si)
}
const bool input_display_enabled = si.GetBoolValue("Display", "ShowInputs", false);
const bool input_display_state = static_cast<bool>(s_input_overlay_ui);
if (input_display_enabled && !s_input_overlay_ui)
s_input_overlay_ui = std::make_unique<FrontendCommon::InputOverlayUI>();
else if (!input_display_enabled && s_input_overlay_ui)

View file

@ -2988,8 +2988,7 @@ void DrawGameListWindow()
if (BeginFullscreenColumnWindow(0.0f, 450.0f, "game_list_info", ImVec4(0.11f, 0.15f, 0.17f, 1.00f)))
{
const auto* window = ImGui::GetCurrentWindow();
const ImVec2 base_pos(window->DC.CursorPos);
const ImGuiWindow* window = ImGui::GetCurrentWindow();
ImGui::SetCursorPos(LayoutScale(ImVec2(50.0f, 50.0f)));
ImGui::Image(selected_entry ? GetGameListCover(selected_entry)->GetHandle() :
@ -4118,7 +4117,6 @@ void DrawAchievementWindow()
const ImVec4 background(0.13f, 0.13f, 0.13f, alpha);
const ImVec2 display_size(ImGui::GetIO().DisplaySize);
const float window_width = LayoutScale(LAYOUT_SCREEN_WIDTH);
const float heading_height = LayoutScale(heading_height_unscaled);
if (BeginFullscreenWindow(
@ -4129,6 +4127,8 @@ void DrawAchievementWindow()
bool visible, hovered;
bool pressed = MenuButtonFrame("achievements_heading", false, heading_height_unscaled, &visible, &hovered, &bb.Min,
&bb.Max, 0, alpha);
UNREFERENCED_VARIABLE(pressed);
if (visible)
{
const float padding = LayoutScale(10.0f);