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

Warnings cleanup #5964

Merged
merged 11 commits into from Jun 27, 2019
20 changes: 15 additions & 5 deletions CMakeLists.txt
Expand Up @@ -2,20 +2,25 @@ cmake_minimum_required(VERSION 3.8.2)

project(rpcs3)

if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
message(FATAL_ERROR "RPCS3 requires at least gcc-8.")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "RPCS3 requires at least clang-5.0.")
endif()
endif()

option(WITH_GDB "WITH_GDB" OFF)
option(USE_NATIVE_INSTRUCTIONS "USE_NATIVE_INSTRUCTIONS makes rpcs3 compile with -march=native, which is useful for local builds, but not good for packages." ON)

option(WITH_LLVM "Enable usage of LLVM library" ON)
option(BUILD_LLVM_SUBMODULE "Build LLVM from git submodule" ON)

option(USE_ALSA "ALSA audio backend" ON)
option(USE_PULSE "PulseAudio audio backend" ON)
option(USE_LIBEVDEV "libevdev-based joystick support" ON)

option(USE_DISCORD_RPC "Discord rich presence integration" ON)

option(USE_SYSTEM_ZLIB "Prefer system ZLIB instead of the builtin one" ON)

option(USE_VULKAN "Vulkan render backend" ON)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/rpcs3/cmake_modules")
Expand Down Expand Up @@ -56,9 +61,14 @@ if(APPLE)
link_directories(/opt/local/lib)
endif()

# Warnings are silenced for 3rdparty code
set(CMAKE_CXX_FLAGS -w)
set(CMAKE_C_FLAGS -w)
add_subdirectory(Vulkan EXCLUDE_FROM_ALL)
add_subdirectory(asmjitsrc EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty)
unset(CMAKE_CXX_FLAGS)
unset(CMAKE_C_FLAGS)

# TODO: do real installation, including copying directory structure
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/bin")
Expand Down
11 changes: 7 additions & 4 deletions Utilities/Thread.cpp
Expand Up @@ -1160,7 +1160,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
}
};

if ((d_size | d_size + addr) >= 0x100000000ull)
if ((d_size | (d_size + addr)) >= 0x100000000ull)
{
LOG_ERROR(MEMORY, "Invalid d_size (0x%llx)", d_size);
report_opcode();
Expand All @@ -1170,7 +1170,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
// get length of data being accessed
size_t a_size = get_x64_access_size(context, op, reg, d_size, i_size);

if ((a_size | a_size + addr) >= 0x100000000ull)
if ((a_size | (a_size + addr)) >= 0x100000000ull)
{
LOG_ERROR(MEMORY, "Invalid a_size (0x%llx)", a_size);
report_opcode();
Expand Down Expand Up @@ -1394,7 +1394,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
}

// Reschedule
cpu->test_stopped();
if (cpu->test_stopped())
{
//
}

if (Emu.IsStopped())
{
Expand Down Expand Up @@ -1692,7 +1695,7 @@ const bool s_exception_handler_set = []() -> bool
#endif

// TODO
extern atomic_t<u32> g_thread_count(0);
atomic_t<u32> g_thread_count(0);

thread_local DECLARE(thread_ctrl::g_tls_this_thread) = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion Utilities/address_range.h
Expand Up @@ -589,4 +589,4 @@ namespace std {
return (size_t{ k.start } << 32) | size_t{ k.end };
}
};
}
}
8 changes: 5 additions & 3 deletions Utilities/cfmt.h
Expand Up @@ -7,6 +7,8 @@
#include <vector>
#include <algorithm>

static const size_t size_dropped = std::numeric_limits<size_t>::max();

/*
C-style format parser. Appends formatted string to `out`, returns number of characters written.
`out`: mutable reference to std::string, std::vector<char> or other compatible container
Expand Down Expand Up @@ -41,7 +43,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
const auto drop_sequence = [&]
{
out.insert(out.end(), fmt - ctx.size, fmt);
ctx.size = -1;
ctx.size = size_dropped;
};

const auto read_decimal = [&](uint result) -> uint
Expand Down Expand Up @@ -112,7 +114,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
ctx = {0};
out.push_back(ch);
}
else if (ctx.size == -1)
else if (ctx.size == size_dropped)
{
out.push_back(ch);
}
Expand Down Expand Up @@ -626,7 +628,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
}

// Handle unfinished sequence
if (ctx.size && ctx.size != -1)
if (ctx.size && ctx.size != size_dropped)
{
fmt--, drop_sequence();
}
Expand Down
2 changes: 1 addition & 1 deletion asmjit
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/StaticHLE.cpp
Expand Up @@ -32,7 +32,7 @@ statichle_handler::~statichle_handler()

bool statichle_handler::load_patterns()
{
for (int i = 0; i < shle_patterns_list.size(); i++)
JohnHolmesII marked this conversation as resolved.
Show resolved Hide resolved
for (u32 i = 0; i < shle_patterns_list.size(); i++)
{
auto& pattern = shle_patterns_list[i];

Expand Down Expand Up @@ -77,7 +77,7 @@ bool statichle_handler::load_patterns()
return (hv << 4) | lv;
};

for (int j = 0; j < 32; j++)
for (u32 j = 0; j < 32; j++)
dapat.start_pattern[j] = char_to_u8(pattern[0][j * 2], pattern[0][(j * 2) + 1]);

dapat.crc16_length = char_to_u8(pattern[1][0], pattern[1][1]);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellAdec.cpp
Expand Up @@ -428,7 +428,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
if (adecIsAtracX(adec.type) && !adec.reader.init)
{
OMAHeader oma(1 /* atrac3p id */, adec.sample_rate, adec.ch_cfg, adec.frame_size);
if (buf_size < sizeof(oma))
if (buf_size + 0u < sizeof(oma))
{
cellAdec.error("adecRead(): OMAHeader writing failed");
Emu.Pause();
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellGem.cpp
Expand Up @@ -853,7 +853,7 @@ s32 cellGemPrepareVideoConvert(vm::cptr<CellGemVideoConvertAttribute> vc_attribu
const auto vc = *vc_attribute;

if (!vc_attribute || vc.version == 0 || vc.output_format == 0 ||
vc.conversion_flags & CELL_GEM_COMBINE_PREVIOUS_INPUT_FRAME && !vc.buffer_memory)
(vc.conversion_flags & CELL_GEM_COMBINE_PREVIOUS_INPUT_FRAME && !vc.buffer_memory))
{
return CELL_GEM_ERROR_INVALID_PARAMETER;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellL10n.cpp
Expand Up @@ -410,7 +410,7 @@ s32 jstrnchk(vm::cptr<u8> src, s32 src_len)
{
u8 r = 0;

for (u32 len = 0; len < src_len; len++)
for (s32 len = 0; len < src_len; len++)
{
if (src != vm::null)
{
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellOskDialog.cpp
Expand Up @@ -144,9 +144,9 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
vm::ptr<u16> string_to_send = vm::cast(vm::alloc(CELL_OSKDIALOG_STRING_SIZE * 2, vm::main));
atomic_t<bool> done = false;
u32 return_value;
u32 i = 0;
u32 i;

for (i; i < CELL_OSKDIALOG_STRING_SIZE - 1; i++)
for (i = 0; i < CELL_OSKDIALOG_STRING_SIZE - 1; i++)
{
string_to_send[i] = osk->osk_text[i];
if (osk->osk_text[i] == 0) break;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellPngDec.cpp
Expand Up @@ -769,9 +769,9 @@ s32 pngDecodeData(ppu_thread& ppu, PHandle handle, PStream stream, vm::ptr<u8> d
// todo: commandptr
try
{
for (int j = 0; j < stream->passes; j++)
for (u32 j = 0; j < stream->passes; j++)
{
for (int i = 0; i < stream->out_param.outputHeight; ++i)
for (u32 i = 0; i < stream->out_param.outputHeight; ++i)
{
const u32 line = flip ? stream->out_param.outputHeight - i - 1 : i;
png_read_row(stream->png_ptr, &data[line*bytes_per_line], nullptr);
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/Modules/cellSysutil.cpp
Expand Up @@ -124,6 +124,7 @@ void fmt_class_string<CellSysutilParamId>::format(std::string& out, u64 arg)
case CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD: return "ID_JAPANESE_KEYBOARD_ENTRY_METHOD";
case CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD: return "ID_CHINESE_KEYBOARD_ENTRY_METHOD";
case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF: return "ID_PAD_AUTOOFF";
case CELL_SYSUTIL_SYSTEMPARAM_ID_MAGNETOMETER: return "ID_MAGNETOMETER";
case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME: return "ID_NICKNAME";
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME: return "ID_CURRENT_USERNAME";
}
Expand Down
12 changes: 8 additions & 4 deletions rpcs3/Emu/Cell/Modules/libmixer.cpp
Expand Up @@ -64,13 +64,17 @@ s32 cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, vm::ptr<float> addr
switch (type)
{
case CELL_SURMIXER_CHSTRIP_TYPE1A:
if (port >= g_surmx.ch_strips_1) type = 0; break;
if (port >= g_surmx.ch_strips_1) type = 0;
break;
case CELL_SURMIXER_CHSTRIP_TYPE2A:
if (port >= g_surmx.ch_strips_2) type = 0; break;
if (port >= g_surmx.ch_strips_2) type = 0;
break;
case CELL_SURMIXER_CHSTRIP_TYPE6A:
if (port >= g_surmx.ch_strips_6) type = 0; break;
if (port >= g_surmx.ch_strips_6) type = 0;
break;
case CELL_SURMIXER_CHSTRIP_TYPE8A:
if (port >= g_surmx.ch_strips_8) type = 0; break;
if (port >= g_surmx.ch_strips_8) type = 0;
break;
default:
type = 0; break;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUInterpreter.cpp
Expand Up @@ -10,7 +10,7 @@
#include <cmath>

#if !defined(_MSC_VER) && !defined(__SSSE3__)
#define _mm_shuffle_epi8
#define _mm_shuffle_epi8(opa, opb) opb
#endif

inline u64 dup32(u32 x) { return x | static_cast<u64>(x) << 32; }
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUTranslator.cpp
Expand Up @@ -1112,7 +1112,7 @@ void PPUTranslator::VMSUMUHS(ppu_opcode_t op)
const auto mh = noncast<u32[4]>((a >> 16) * (b >> 16));
const auto s = eval(ml + mh);
const auto s2 = eval(s + c);
const auto x = eval(s < ml | s2 < s);
const auto x = eval((s < ml) | (s2 < s));
set_vr(op.vd, select(x, splat<u32[4]>(-1), s2));
SetSat(IsNotZero(x.value));
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp
Expand Up @@ -2817,7 +2817,7 @@ void spu_recompiler::FSMB(spu_opcode_t op)
c->pshufd(va, va, 0xfa);
}

c->movdqa(vm, XmmConst(_mm_set_epi8(128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1)));
c->movdqa(vm, XmmConst(_mm_set_epi8(-128, 64, 32, 16, 8, 4, 2, 1, -128, 64, 32, 16, 8, 4, 2, 1)));
JohnHolmesII marked this conversation as resolved.
Show resolved Hide resolved
c->pand(va, vm);
c->pcmpeqb(va, vm);
c->movdqa(SPU_OFF_128(gpr, op.rt), va);
Expand Down
18 changes: 9 additions & 9 deletions rpcs3/Emu/Cell/SPUInterpreter.cpp
Expand Up @@ -333,13 +333,13 @@ bool spu_interpreter::ROTI(spu_thread& spu, spu_opcode_t op)

bool spu_interpreter::ROTMI(spu_thread& spu, spu_opcode_t op)
{
spu.gpr[op.rt].vi = _mm_srli_epi32(spu.gpr[op.ra].vi, 0-op.i7 & 0x3f);
spu.gpr[op.rt].vi = _mm_srli_epi32(spu.gpr[op.ra].vi, (0-op.i7) & 0x3f);
return true;
}

bool spu_interpreter::ROTMAI(spu_thread& spu, spu_opcode_t op)
{
spu.gpr[op.rt].vi = _mm_srai_epi32(spu.gpr[op.ra].vi, 0-op.i7 & 0x3f);
spu.gpr[op.rt].vi = _mm_srai_epi32(spu.gpr[op.ra].vi, (0-op.i7) & 0x3f);
return true;
}

Expand All @@ -359,13 +359,13 @@ bool spu_interpreter::ROTHI(spu_thread& spu, spu_opcode_t op)

bool spu_interpreter::ROTHMI(spu_thread& spu, spu_opcode_t op)
{
spu.gpr[op.rt].vi = _mm_srli_epi16(spu.gpr[op.ra].vi, 0-op.i7 & 0x1f);
spu.gpr[op.rt].vi = _mm_srli_epi16(spu.gpr[op.ra].vi, (0-op.i7) & 0x1f);
return true;
}

bool spu_interpreter::ROTMAHI(spu_thread& spu, spu_opcode_t op)
{
spu.gpr[op.rt].vi = _mm_srai_epi16(spu.gpr[op.ra].vi, 0-op.i7 & 0x1f);
spu.gpr[op.rt].vi = _mm_srai_epi16(spu.gpr[op.ra].vi, (0-op.i7) & 0x1f);
return true;
}

Expand Down Expand Up @@ -572,7 +572,7 @@ bool spu_interpreter::FSMB(spu_thread& spu, spu_opcode_t op)
{
const auto vsrc = spu.gpr[op.ra].vi;
const auto bits = _mm_shuffle_epi32(_mm_shufflehi_epi16(_mm_unpackhi_epi8(vsrc, vsrc), 0x50), 0xfa);
const auto mask = _mm_set_epi8(128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1);
const auto mask = _mm_set_epi8(-128, 64, 32, 16, 8, 4, 2, 1, -128, 64, 32, 16, 8, 4, 2, 1);
spu.gpr[op.rt].vi = _mm_cmpeq_epi8(_mm_and_si128(bits, mask), mask);
return true;
}
Expand Down Expand Up @@ -708,7 +708,7 @@ bool spu_interpreter::ROTQMBY(spu_thread& spu, spu_opcode_t op)
{
const auto a = spu.gpr[op.ra].vi;
alignas(64) const __m128i buf[3]{a, _mm_setzero_si128(), _mm_setzero_si128()};
spu.gpr[op.rt].vi = _mm_loadu_si128((__m128i*)((u8*)buf + (0 - spu.gpr[op.rb]._u32[3] & 0x1f)));
spu.gpr[op.rt].vi = _mm_loadu_si128((__m128i*)((u8*)buf + ((0 - spu.gpr[op.rb]._u32[3]) & 0x1f)));
return true;
}

Expand Down Expand Up @@ -789,7 +789,7 @@ bool spu_interpreter::ROTQBII(spu_thread& spu, spu_opcode_t op)
bool spu_interpreter::ROTQMBII(spu_thread& spu, spu_opcode_t op)
{
const auto a = spu.gpr[op.ra].vi;
const s32 n = 0-op.i7 & 0x7;
const s32 n = (0-op.i7) & 0x7;
spu.gpr[op.rt].vi = _mm_or_si128(_mm_srli_epi64(a, n), _mm_slli_epi64(_mm_srli_si128(a, 8), 64 - n));
return true;
}
Expand All @@ -814,7 +814,7 @@ bool spu_interpreter::ROTQMBYI(spu_thread& spu, spu_opcode_t op)
{
const auto a = spu.gpr[op.ra].vi;
alignas(64) const __m128i buf[3]{a, _mm_setzero_si128(), _mm_setzero_si128()};
spu.gpr[op.rt].vi = _mm_loadu_si128((__m128i*)((u8*)buf + (0 - op.i7 & 0x1f)));
spu.gpr[op.rt].vi = _mm_loadu_si128((__m128i*)((u8*)buf + ((0 - op.i7) & 0x1f)));
return true;
}

Expand Down Expand Up @@ -1429,7 +1429,7 @@ bool spu_interpreter::FSMBI(spu_thread& spu, spu_opcode_t op)
{
const auto vsrc = _mm_set_epi32(0, 0, 0, op.i16);
const auto bits = _mm_shuffle_epi32(_mm_shufflelo_epi16(_mm_unpacklo_epi8(vsrc, vsrc), 0x50), 0x50);
const auto mask = _mm_set_epi8(128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1);
const auto mask = _mm_set_epi8(-128, 64, 32, 16, 8, 4, 2, 1, -128, 64, 32, 16, 8, 4, 2, 1);
spu.gpr[op.rt].vi = _mm_cmpeq_epi8(_mm_and_si128(bits, mask), mask);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -2995,7 +2995,7 @@ bool spu_thread::stop_and_signal(u32 code)
{
if (spuq == v.first)
{
if (queue = v.second.lock())
if ((queue = v.second.lock()))
{
break;
}
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/lv2/lv2.cpp
Expand Up @@ -913,6 +913,7 @@ void fmt_class_string<CellError>::format(std::string& out, u64 arg)
STR_CASE(CELL_ETIMEDOUT);
STR_CASE(CELL_EABORT);
STR_CASE(CELL_EFAULT);
STR_CASE(CELL_ENOCHILD);
STR_CASE(CELL_ESTAT);
STR_CASE(CELL_EALIGN);
STR_CASE(CELL_EKRESOURCE);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Common/BufferUtils.cpp
Expand Up @@ -15,7 +15,7 @@ const bool s_use_ssse3 =
true;
#else
false;
#define _mm_shuffle_epi8
#define _mm_shuffle_epi8(opa, opb) opb
#endif

namespace
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Common/ProgramStateCache.cpp
Expand Up @@ -155,7 +155,7 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert
}
}

if (d3.end && (fast_exit || current_instrution >= instruction_range.second) ||
if ((d3.end && (fast_exit || current_instrution >= instruction_range.second)) ||
(current_instrution + 1) == 512)
{
break;
Expand Down