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;