Skip to content

Commit

Permalink
Warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Sep 17, 2022
1 parent e7fd84e commit 02386e7
Show file tree
Hide file tree
Showing 63 changed files with 165 additions and 208 deletions.
5 changes: 3 additions & 2 deletions Utilities/File.h
Expand Up @@ -74,7 +74,7 @@ namespace fs

using enable_bitcopy = std::true_type;

constexpr bool operator==(const stat_t&) const = default;
constexpr bool operator==(const stat_t&) const = default;
};

// Helper, layout is equal to iovec struct
Expand Down Expand Up @@ -793,7 +793,8 @@ namespace fs

if (write)
{
m_stat.mtime = std::max(m_stat.atime, ++m_stat.mtime);
m_stat.mtime++;
m_stat.mtime = std::max(m_stat.atime, m_stat.mtime);
m_stat.ctime = m_stat.mtime;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Utilities/Thread.cpp
Expand Up @@ -16,7 +16,9 @@
#include <process.h>
#include <sysinfoapi.h>
#else
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifdef __APPLE__
#define _XOPEN_SOURCE
#define __USE_GNU
Expand Down
6 changes: 4 additions & 2 deletions Utilities/version.cpp
Expand Up @@ -30,7 +30,8 @@ namespace utils

if (lo())
{
version += "." + std::to_string(lo());
version += '.';
version += std::to_string(lo());
}

if (type() != version_type::release)
Expand All @@ -40,7 +41,8 @@ namespace utils
version += "-" + postfix();
}

version += " " + utils::to_string(type());
version += ' ';
version += utils::to_string(type());

if (type_index() > 1)
{
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/Emu/CPU/CPUThread.cpp
Expand Up @@ -55,6 +55,7 @@ void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
case cpu_flag::memory: return "mem";
case cpu_flag::pending: return "pend";
case cpu_flag::pending_recheck: return "pend-re";
case cpu_flag::notify: return "ntf";
case cpu_flag::yield: return "y";
case cpu_flag::preempt: return "PREEMPT";
case cpu_flag::dbg_global_pause: return "G-PAUSE";
Expand Down Expand Up @@ -648,7 +649,7 @@ bool cpu_thread::check_state() noexcept
{
bool cpu_sleep_called = false;
bool cpu_can_stop = true;
bool escape, retval;
bool escape{}, retval{};

while (true)
{
Expand Down
37 changes: 3 additions & 34 deletions rpcs3/Emu/Cell/Modules/cellAdec.cpp
Expand Up @@ -454,30 +454,8 @@ class AudioDecoder : public ppu_thread
if (adecIsAtracX(type)) last_pts -= 0x10000; // hack
}

struct AVPacketHolder : AVPacket
{
AVPacketHolder(u32 data_size)
{
av_init_packet(this);

if (data_size)
{
this->data = static_cast<u8*>(av_calloc(1, data_size + AV_INPUT_BUFFER_PADDING_SIZE));
this->size = data_size + AV_INPUT_BUFFER_PADDING_SIZE;
}
else
{
this->data = nullptr;
this->size = 0;
}
}

~AVPacketHolder()
{
av_free(data);
}

} au(0);
AVPacket* packet = av_packet_alloc();
std::unique_ptr<AVPacket, decltype([](AVPacket* p){av_packet_unref(p);})> packet_(packet);

if (just_started && just_finished)
{
Expand Down Expand Up @@ -544,8 +522,6 @@ class AudioDecoder : public ppu_thread
just_started = false;
}

bool last_frame = false;

while (true)
{
if (Emu.IsStopped() || is_closed)
Expand All @@ -554,14 +530,7 @@ class AudioDecoder : public ppu_thread
break;
}

last_frame = av_read_frame(fmt, &au) < 0;
if (last_frame)
{
//break;
av_free(au.data);
au.data = NULL;
au.size = 0;
}
av_read_frame(fmt, packet);

struct AdecFrameHolder : AdecFrame
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellCamera.cpp
Expand Up @@ -175,7 +175,7 @@ static error_code check_camera_info(const VariantOfCellCameraInfo& info)
return CELL_CAMERA_ERROR_BAD_FRAMERATE;
}

auto check_fps = [fps = info.framerate](const std::vector<s32>& range)
auto check_fps = [fps = info.framerate](std::initializer_list<s32> range)
{
return std::find(range.begin(), range.end(), fps) != range.end();
};
Expand Down
2 changes: 0 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellCamera.h
Expand Up @@ -477,5 +477,3 @@ struct gem_camera_shared
atomic_t<s32> size{0};
atomic_t<CellCameraFormat> format{CELL_CAMERA_RAW8};
};

static inline s32 get_video_buffer_size(s32 width, s32 height);
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/Modules/cellCrossController.cpp
Expand Up @@ -52,7 +52,7 @@ struct cross_controller

close_msg_dialog();

sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([this, status](ppu_thread& ppu) -> s32
{
callback(ppu, CELL_CROSS_CONTROLLER_STATUS_FINALIZED, status, vm::null, userdata);
return CELL_OK;
Expand All @@ -74,9 +74,9 @@ struct cross_controller
// TODO: Show icons from comboplay_plugin.rco in dialog. Maybe use a new dialog or add an optional icon to this one.
error_code res = open_msg_dialog(false, CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF, vm::make_str(msg), msg_dialog_callback, userdata);

sysutil_register_cb([=](ppu_thread& ppu) -> s32
sysutil_register_cb([this, res](ppu_thread& ppu) -> s32
{
callback(ppu, CELL_CROSS_CONTROLLER_STATUS_INITIALIZED, res == CELL_OK ? CELL_OK : CELL_CROSS_CONTROLLER_ERROR_INTERNAL, vm::null, userdata);
callback(ppu, CELL_CROSS_CONTROLLER_STATUS_INITIALIZED, res == CELL_OK ? +CELL_OK : +CELL_CROSS_CONTROLLER_ERROR_INTERNAL, vm::null, userdata);
return CELL_OK;
});

Expand Down
3 changes: 2 additions & 1 deletion rpcs3/Emu/Cell/Modules/cellGame.cpp
Expand Up @@ -1531,7 +1531,8 @@ error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr<char
return CELL_GAME_ERROR_PARAM;
}

error_msg += "\n" + get_localized_string(localized_string_id::CELL_GAME_ERROR_DIR_NAME, fmt::format("%s", dirName).c_str());
error_msg += '\n';
error_msg += get_localized_string(localized_string_id::CELL_GAME_ERROR_DIR_NAME, fmt::format("%s", dirName).c_str());
}

return open_exit_dialog(error_msg, type > CELL_GAME_ERRDIALOG_NOSPACE);
Expand Down
4 changes: 1 addition & 3 deletions rpcs3/Emu/Cell/Modules/cellGcmSys.cpp
Expand Up @@ -322,7 +322,7 @@ error_code cellGcmBindZcull(u8 index, u32 offset, u32 width, u32 height, u32 cul
{
return err;
}

vm::_ptr<CellGcmZcullInfo>(gcm_cfg.zculls_addr)[index] = gcm_zcull;
return CELL_OK;
}
Expand Down Expand Up @@ -1314,8 +1314,6 @@ void _cellGcmSetFlipCommandWithWaitLabel(ppu_thread& ppu, vm::ptr<CellGcmContext
{
cellGcmSys.warning("cellGcmSetFlipCommandWithWaitLabel(ctx=*0x%x, id=0x%x, label_index=0x%x, label_value=0x%x)", ctx, id, label_index, label_value);

auto& gcm_cfg = g_fxo->get<gcm_config>();

rsx::make_command(ctx->current, NV406E_SEMAPHORE_OFFSET, { label_index * 0x10, label_value });

if (auto error = gcmSetPrepareFlip<true>(ppu, ctx, id); error < 0)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellGem.cpp
Expand Up @@ -446,7 +446,7 @@ static bool check_gem_num(const u32 gem_num)
return gem_num < CELL_GEM_MAX_NUM;
}

static inline void draw_overlay_cursor(u32 gem_num, const gem_config::gem_controller& controller, s32 x_pos, s32 y_pos, s32 x_max, s32 y_max)
static inline void draw_overlay_cursor(u32 gem_num, const gem_config::gem_controller&, s32 x_pos, s32 y_pos, s32 x_max, s32 y_max)
{
const u16 x = static_cast<u16>(x_pos / (x_max / static_cast<f32>(rsx::overlays::overlay::virtual_width)));
const u16 y = static_cast<u16>(y_pos / (y_max / static_cast<f32>(rsx::overlays::overlay::virtual_height)));
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/Modules/cellHttp.cpp
Expand Up @@ -1120,7 +1120,7 @@ error_code cellHttpAuthCacheExport(vm::ptr<u32> buf, u32 len, vm::ptr<u32> outsi
// TODO
}

u32 size = 0;
[[maybe_unused]] u32 size = 0;

// TODO

Expand Down Expand Up @@ -2786,7 +2786,7 @@ error_code cellHttpClientAddHeader(CellHttpClientId clientId, vm::cptr<CellHttpH
error_code cellHttpClientDeleteHeader(CellHttpClientId clientId, vm::cptr<char> name)
{
cellHttp.todo("cellHttpClientDeleteHeader(clientId=0x%x, name=%s)", clientId, name);

auto& man = g_fxo->get<http_manager>();
std::lock_guard lock(man.mtx);

Expand All @@ -2806,7 +2806,7 @@ error_code cellHttpClientDeleteHeader(CellHttpClientId clientId, vm::cptr<char>
error_code cellHttpClientSetSslCallback(CellHttpClientId clientId, vm::ptr<CellHttpsSslCallback> cbfunc, vm::ptr<void> userArg)
{
cellHttp.todo("cellHttpClientSetSslCallback(clientId=0x%x, cbfunc=*0x%x, userArg=*0x%x)", clientId, cbfunc, userArg);

auto& man = g_fxo->get<http_manager>();
std::lock_guard lock(man.mtx);

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp
Expand Up @@ -230,7 +230,7 @@ error_code cellHttpUtilBuildRequestLine(vm::cptr<CellHttpRequestLine> req, vm::p
std::string path = fmt::format("%s", req->path);
if (path.empty())
{
path = "/";
path += '/';
}

// TODO: are the numbers properly formatted ?
Expand Down Expand Up @@ -805,7 +805,7 @@ error_code cellHttpUtilBase64Encoder(vm::ptr<char> out, vm::cptr<void> input, u3

error_code cellHttpUtilBase64Decoder(vm::ptr<char> output, vm::cptr<void> in, u32 len)
{
cellHttpUtil.todo("cellHttpUtilBase64Decoder(output=*0x%x, in=*0x%x, len=%d)", output, in, len);
cellHttpUtil.todo("cellHttpUtilBase64Decoder(output=*0x%x, in=*0x%x, len=%d)", output, in, len);

if (!in)
{
Expand Down
7 changes: 3 additions & 4 deletions rpcs3/Emu/Cell/Modules/cellImeJp.cpp
Expand Up @@ -43,10 +43,9 @@ bool ime_jp_manager::addChar(u16 c)
if (!c || cursor >= (CELL_IMEJP_STRING_MAXLENGTH - 1) || cursor > input_string.length())
return false;

std::u16string tmp;
tmp += c;
input_string.insert(cursor++, tmp);
cursor_end = cursor;
input_string += c; // resize
std::memmove(input_string.data() + cursor + 1, input_string.data() + cursor, sizeof(u16) * (input_string.size() - 1 - cursor));
cursor_end = ++cursor;
input_state = CELL_IMEJP_BEFORE_CONVERT;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellKb.cpp
Expand Up @@ -49,7 +49,7 @@ KeyboardHandlerBase::KeyboardHandlerBase(utils::serial* ar)
Emu.DeferDeserialization([this]()
{
Init(m_info.max_connect);
init.init();
auto lk = init.init();
});
}
}
Expand Down
2 changes: 0 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellKb.h
Expand Up @@ -56,5 +56,3 @@ struct CellKbConfig
be_t<u32> read_mode;
be_t<u32> code_type;
};

u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode);
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellMouse.cpp
Expand Up @@ -49,7 +49,7 @@ MouseHandlerBase::MouseHandlerBase(utils::serial* ar)
Emu.DeferDeserialization([this]()
{
Init(m_info.max_connect);
init.init();
auto lk = init.init();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellPngEnc.cpp
Expand Up @@ -42,7 +42,7 @@ bool check_config(vm::cptr<CellPngEncConfig> config)
if (!config ||
config->maxWidth == 0u || config->maxWidth > 1000000u ||
config->maxHeight == 0u || config->maxHeight > 1000000u ||
config->maxBitDepth != 8u && config->maxBitDepth != 16u ||
(config->maxBitDepth != 8u && config->maxBitDepth != 16u) ||
static_cast<s32>(config->addMemSize) < 0 ||
config->exParamNum != 0u)
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellSaveData.cpp
Expand Up @@ -148,7 +148,7 @@ int check_filename(std::string_view file_path, bool disallow_system_files, bool
return 70;
}

char name[CELL_SAVEDATA_FILENAME_SIZE - 3];
char name[CELL_SAVEDATA_FILENAME_SIZE + 3];

if (dotpos)
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp
Expand Up @@ -315,7 +315,7 @@ error_code cellSysutilAvc2EstimateMemoryContainerSize(vm::cptr<CellSysutilAvc2In
val += static_cast<s32>(static_cast<f64>(window_count) * 1258291.2) + 0x1ed846;
}

estimated_size = (estimated_size + ((static_cast<int>(val) >> 7) + static_cast<u32>(static_cast<int>(val) < 0 && (val & 0x7f) != 0)) * 0x80 + 0x80080 & 0xfff00000) + 0x100000;
estimated_size = ((estimated_size + ((static_cast<int>(val) >> 7) + static_cast<u32>(static_cast<int>(val) < 0 && (val & 0x7f) != 0)) * 0x80 + 0x80080) & 0xfff00000) + 0x100000;

*size = estimated_size;
}
Expand Down
4 changes: 1 addition & 3 deletions rpcs3/Emu/Cell/Modules/cellVdec.cpp
Expand Up @@ -636,14 +636,12 @@ struct vdec_creation_lock

vdec_creation_lock()
{
locked.init();
auto lk = locked.init();
}
};

extern bool try_lock_vdec_context_creation()
{
bool exist = false;

auto& lock = g_fxo->get<vdec_creation_lock>();
auto reset = lock.locked.reset();

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/sceNpUtil.cpp
Expand Up @@ -69,7 +69,7 @@ struct sce_np_util_manager
}
};

error_code sceNpUtilBandwidthTestInitStart(ppu_thread& ppu, u32 prio, u32 stack)
error_code sceNpUtilBandwidthTestInitStart([[maybe_unused]] ppu_thread& ppu, u32 prio, u32 stack)
{
sceNpUtil.todo("sceNpUtilBandwidthTestInitStart(prio=%d, stack=%d)", prio, stack);

Expand Down Expand Up @@ -101,7 +101,7 @@ error_code sceNpUtilBandwidthTestGetStatus()
return not_an_error(util_manager.bandwidth_test_thread->status);
}

error_code sceNpUtilBandwidthTestShutdown(ppu_thread& ppu, vm::ptr<SceNpUtilBandwidthTestResult> result)
error_code sceNpUtilBandwidthTestShutdown([[maybe_unused]] ppu_thread& ppu, vm::ptr<SceNpUtilBandwidthTestResult> result)
{
sceNpUtil.warning("sceNpUtilBandwidthTestShutdown(result=*0x%x)", result);

Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/PPUInterpreter.cpp
Expand Up @@ -23,6 +23,7 @@
#if !defined(_MSC_VER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif

extern bool is_debugger_present();
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/Cell/PPUModule.cpp
Expand Up @@ -38,7 +38,7 @@ extern void sys_initialize_tls(ppu_thread&, u64, u32, u32, u32);
// HLE function name cache
std::vector<std::string> g_ppu_function_names;

extern atomic_t<u32> liblv2_begin = 0, liblv2_end = 0;
atomic_t<u32> liblv2_begin = 0, liblv2_end = 0;

extern u32 ppu_generate_id(std::string_view name)
{
Expand Down Expand Up @@ -340,7 +340,7 @@ static void ppu_initialize_modules(ppu_linkage_info* link, utils::serial* ar = n
while (true)
{
const std::string name = ar.operator std::string();

if (name.empty())
{
// Null termination
Expand All @@ -350,7 +350,7 @@ static void ppu_initialize_modules(ppu_linkage_info* link, utils::serial* ar = n
const auto _module = manager.at(name);

auto& variable = _module->variables;

for (u32 i = 0, end = ar.operator usz(); i < end; i++)
{
auto* ptr = &variable.at(ar.operator u32());
Expand Down Expand Up @@ -2466,7 +2466,7 @@ bool ppu_load_rel_exec(const ppu_rel_object& elf)
const auto& s = *ptr;

ppu_loader.notice("** Section: sh_type=0x%x, addr=0x%llx, size=0x%llx, flags=0x%x", std::bit_cast<u32>(s.sh_type), s.sh_addr, s.sh_size, s._sh_flags);

if (s.sh_type == sec_type::sht_progbits && s.sh_size && s.sh_flags().all_of(sh_flag::shf_alloc))
{
ppu_segment _sec;
Expand Down

0 comments on commit 02386e7

Please sign in to comment.