Fixing most remaining C++ warnings in clang.
This commit is contained in:
parent
e029c9abdc
commit
b02ca62388
|
@ -7,17 +7,13 @@ project("xenia-debug-ui")
|
|||
kind("StaticLib")
|
||||
language("C++")
|
||||
links({
|
||||
"glew",
|
||||
"imgui",
|
||||
"xenia-base",
|
||||
"xenia-cpu",
|
||||
"xenia-debug",
|
||||
"xenia-ui",
|
||||
"xenia-ui-gl",
|
||||
})
|
||||
defines({
|
||||
"GLEW_STATIC=1",
|
||||
"GLEW_MX=1",
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/gflags/src",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/export_resolver.h"
|
||||
|
@ -29,7 +30,7 @@ namespace kernel {
|
|||
|
||||
using PPCContext = xe::cpu::ppc::PPCContext;
|
||||
|
||||
#define SHIM_CALL void _cdecl
|
||||
#define SHIM_CALL void __cdecl
|
||||
#define SHIM_SET_MAPPING(library_name, export_name, shim_data) \
|
||||
export_resolver->SetFunctionMapping( \
|
||||
library_name, ordinals::export_name, \
|
||||
|
@ -403,7 +404,7 @@ void PrintKernelCall(cpu::Export* export_entry, const Tuple& params) {
|
|||
string_buffer.Append('(');
|
||||
AppendKernelCallParams(string_buffer, export_entry, params);
|
||||
string_buffer.Append(')');
|
||||
if (export_entry->tags & ExportTag::kImportant) {
|
||||
if (export_entry->tags & xe::cpu::ExportTag::kImportant) {
|
||||
xe::LogLine('i', string_buffer.GetString(), string_buffer.length());
|
||||
} else {
|
||||
xe::LogLine('d', string_buffer.GetString(), string_buffer.length());
|
||||
|
@ -418,9 +419,9 @@ auto KernelTrampoline(F&& f, Tuple&& t, std::index_sequence<I...>) {
|
|||
template <KernelModuleId MODULE, uint16_t ORDINAL, typename R, typename... Ps>
|
||||
xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name,
|
||||
xe::cpu::ExportTag::type tags) {
|
||||
static const auto export_entry =
|
||||
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||
tags | ExportTag::kImplemented | ExportTag::kLog);
|
||||
static const auto export_entry = new cpu::Export(
|
||||
ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||
tags | xe::cpu::ExportTag::kImplemented | xe::cpu::ExportTag::kLog);
|
||||
static R (*FN)(Ps&...) = fn;
|
||||
struct X {
|
||||
static void Trampoline(PPCContext* ppc_context) {
|
||||
|
@ -429,8 +430,8 @@ xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name,
|
|||
ppc_context, sizeof...(Ps), 0,
|
||||
};
|
||||
auto params = std::make_tuple<Ps...>(Ps(init)...);
|
||||
if (export_entry->tags & ExportTag::kLog &&
|
||||
(!(export_entry->tags & ExportTag::kHighFrequency) ||
|
||||
if (export_entry->tags & xe::cpu::ExportTag::kLog &&
|
||||
(!(export_entry->tags & xe::cpu::ExportTag::kHighFrequency) ||
|
||||
FLAGS_log_high_frequency_kernel_calls)) {
|
||||
PrintKernelCall(export_entry, params);
|
||||
}
|
||||
|
@ -438,7 +439,8 @@ xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name,
|
|||
KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params),
|
||||
std::make_index_sequence<sizeof...(Ps)>());
|
||||
result.Store(ppc_context);
|
||||
if (export_entry->tags & (ExportTag::kLog | ExportTag::kLogResult)) {
|
||||
if (export_entry->tags &
|
||||
(xe::cpu::ExportTag::kLog | xe::cpu::ExportTag::kLogResult)) {
|
||||
// TODO(benvanik): log result.
|
||||
}
|
||||
}
|
||||
|
@ -450,9 +452,9 @@ xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name,
|
|||
template <KernelModuleId MODULE, uint16_t ORDINAL, typename... Ps>
|
||||
xe::cpu::Export* RegisterExport(void (*fn)(Ps&...), const char* name,
|
||||
xe::cpu::ExportTag::type tags) {
|
||||
static const auto export_entry =
|
||||
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||
tags | ExportTag::kImplemented | ExportTag::kLog);
|
||||
static const auto export_entry = new cpu::Export(
|
||||
ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||
tags | xe::cpu::ExportTag::kImplemented | xe::cpu::ExportTag::kLog);
|
||||
static void (*FN)(Ps&...) = fn;
|
||||
struct X {
|
||||
static void Trampoline(PPCContext* ppc_context) {
|
||||
|
@ -461,8 +463,8 @@ xe::cpu::Export* RegisterExport(void (*fn)(Ps&...), const char* name,
|
|||
ppc_context, sizeof...(Ps),
|
||||
};
|
||||
auto params = std::make_tuple<Ps...>(Ps(init)...);
|
||||
if (export_entry->tags & ExportTag::kLog &&
|
||||
(!(export_entry->tags & ExportTag::kHighFrequency) ||
|
||||
if (export_entry->tags & xe::cpu::ExportTag::kLog &&
|
||||
(!(export_entry->tags & xe::cpu::ExportTag::kHighFrequency) ||
|
||||
FLAGS_log_high_frequency_kernel_calls)) {
|
||||
PrintKernelCall(export_entry, params);
|
||||
}
|
||||
|
|
|
@ -869,9 +869,17 @@ int xe_xex2_load_pe(xe_xex2_ref xex) {
|
|||
// IAT Import Address Table ptr
|
||||
// opthdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_X].VirtualAddress / .Size
|
||||
|
||||
// The macros in pe_image.h don't work with clang, for some reason.
|
||||
// offsetof seems to be unable to find OptionalHeader.
|
||||
#define offsetof1(type, member) ((std::size_t) & (((type*)0)->member))
|
||||
#define IMAGE_FIRST_SECTION1(ntheader) \
|
||||
((PIMAGE_SECTION_HEADER)( \
|
||||
(uint8_t*)ntheader + offsetof1(IMAGE_NT_HEADERS, OptionalHeader) + \
|
||||
((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
|
||||
|
||||
// Quick scan to determine bounds of sections.
|
||||
size_t upper_address = 0;
|
||||
const IMAGE_SECTION_HEADER* sechdr = IMAGE_FIRST_SECTION(nthdr);
|
||||
const IMAGE_SECTION_HEADER* sechdr = IMAGE_FIRST_SECTION1(nthdr);
|
||||
for (size_t n = 0; n < filehdr->NumberOfSections; n++, sechdr++) {
|
||||
const size_t physical_address = opthdr->ImageBase + sechdr->VirtualAddress;
|
||||
upper_address =
|
||||
|
@ -879,7 +887,7 @@ int xe_xex2_load_pe(xe_xex2_ref xex) {
|
|||
}
|
||||
|
||||
// Setup/load sections.
|
||||
sechdr = IMAGE_FIRST_SECTION(nthdr);
|
||||
sechdr = IMAGE_FIRST_SECTION1(nthdr);
|
||||
for (size_t n = 0; n < filehdr->NumberOfSections; n++, sechdr++) {
|
||||
PESection* section = (PESection*)calloc(1, sizeof(PESection));
|
||||
memcpy(section->name, sechdr->Name, sizeof(sechdr->Name));
|
||||
|
|
|
@ -182,7 +182,9 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
|
|||
|
||||
// Get all content data.
|
||||
auto content_datas = kernel_state()->content_manager()->ListContent(
|
||||
device_id ? device_id : dummy_device_info_.device_id, content_type);
|
||||
device_id ? static_cast<uint32_t>(device_id)
|
||||
: dummy_device_info_.device_id,
|
||||
content_type);
|
||||
for (auto& content_data : content_datas) {
|
||||
auto ptr = e->AppendItem();
|
||||
if (!ptr) {
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace xe {
|
|||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
std::atomic<int> xam_dialogs_shown_ = 0;
|
||||
std::atomic<int> xam_dialogs_shown_ = {0};
|
||||
|
||||
SHIM_CALL XamIsUIActive_shim(PPCContext* ppc_context,
|
||||
KernelState* kernel_state) {
|
||||
|
@ -54,7 +54,7 @@ class MessageBoxDialog : public xe::ui::ImGuiDialog {
|
|||
}
|
||||
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text(description_.c_str());
|
||||
ImGui::Text("%s", description_.c_str());
|
||||
if (first_draw) {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ class KeyboardInputDialog : public xe::ui::ImGuiDialog {
|
|||
}
|
||||
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::TextWrapped(description_.c_str());
|
||||
ImGui::TextWrapped("%s", description_.c_str());
|
||||
if (first_draw) {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
}
|
||||
|
|
|
@ -196,9 +196,10 @@ dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
|
|||
if (true || file->is_synchronous()) {
|
||||
// Synchronous.
|
||||
size_t bytes_read = 0;
|
||||
result = file->Read(buffer, buffer_length,
|
||||
byte_offset_ptr ? *byte_offset_ptr : -1, &bytes_read,
|
||||
apc_context);
|
||||
result = file->Read(
|
||||
buffer, buffer_length,
|
||||
byte_offset_ptr ? static_cast<uint32_t>(*byte_offset_ptr) : -1u,
|
||||
&bytes_read, apc_context);
|
||||
if (io_status_block) {
|
||||
io_status_block->status = result;
|
||||
io_status_block->information = static_cast<uint32_t>(bytes_read);
|
||||
|
@ -210,8 +211,8 @@ dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
|
|||
if ((uint32_t)apc_routine_ptr & ~1) {
|
||||
if (apc_context) {
|
||||
auto thread = XThread::GetCurrentThread();
|
||||
thread->EnqueueApc((uint32_t)apc_routine_ptr & ~1, apc_context,
|
||||
io_status_block, 0);
|
||||
thread->EnqueueApc(static_cast<uint32_t>(apc_routine_ptr) & ~1u,
|
||||
apc_context, io_status_block, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,8 +287,9 @@ dword_result_t NtWriteFile(dword_t file_handle, dword_t event_handle,
|
|||
if (true || file->is_synchronous()) {
|
||||
// Synchronous request.
|
||||
size_t bytes_written = 0;
|
||||
result = file->Write(buffer, buffer_length,
|
||||
byte_offset_ptr ? *byte_offset_ptr : -1,
|
||||
result = file->Write(
|
||||
buffer, buffer_length,
|
||||
byte_offset_ptr ? static_cast<uint32_t>(*byte_offset_ptr) : -1u,
|
||||
&bytes_written, apc_context);
|
||||
if (XSUCCEEDED(result)) {
|
||||
info = (int32_t)bytes_written;
|
||||
|
@ -356,7 +358,7 @@ dword_result_t NtRemoveIoCompletion(
|
|||
status = X_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
uint64_t timeout_ticks = timeout ? *timeout : 0;
|
||||
uint64_t timeout_ticks = timeout ? static_cast<uint32_t>(*timeout) : 0u;
|
||||
if (port->WaitForNotification(timeout_ticks)) {
|
||||
auto notification = port->DequeueNotification();
|
||||
if (key_context) {
|
||||
|
|
|
@ -323,7 +323,8 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_context,
|
|||
void AppendParam(StringBuffer* string_buffer,
|
||||
pointer_t<X_EX_TITLE_TERMINATE_REGISTRATION> reg) {
|
||||
string_buffer->AppendFormat("%.8X(%.8X, %.8X)", reg.guest_address(),
|
||||
reg->notification_routine, reg->priority);
|
||||
static_cast<uint32_t>(reg->notification_routine),
|
||||
static_cast<uint32_t>(reg->priority));
|
||||
}
|
||||
|
||||
void ExRegisterTitleTerminateNotification(
|
||||
|
|
|
@ -832,7 +832,7 @@ dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
|||
return X_STATUS_ABANDONED_WAIT_0;
|
||||
}
|
||||
|
||||
uint64_t timeout = timeout_ptr ? *timeout_ptr : 0;
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint32_t>(*timeout_ptr) : 0u;
|
||||
X_STATUS result = object->Wait(wait_reason, processor_mode, alertable,
|
||||
timeout_ptr ? &timeout : nullptr);
|
||||
|
||||
|
@ -850,7 +850,7 @@ dword_result_t NtWaitForSingleObjectEx(dword_t object_handle, dword_t wait_mode,
|
|||
auto object =
|
||||
kernel_state()->object_table()->LookupObject<XObject>(object_handle);
|
||||
if (object) {
|
||||
uint64_t timeout = timeout_ptr ? *timeout_ptr : 0;
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint32_t>(*timeout_ptr) : 0u;
|
||||
result =
|
||||
object->Wait(3, wait_mode, alertable, timeout_ptr ? &timeout : nullptr);
|
||||
} else {
|
||||
|
@ -885,7 +885,7 @@ dword_result_t KeWaitForMultipleObjects(dword_t count, lpdword_t objects_ptr,
|
|||
objects.push_back(std::move(object_ref));
|
||||
}
|
||||
|
||||
uint64_t timeout = timeout_ptr ? *timeout_ptr : 0;
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint32_t>(*timeout_ptr) : 0u;
|
||||
result = XObject::WaitMultiple(uint32_t(objects.size()),
|
||||
reinterpret_cast<XObject**>(objects.data()),
|
||||
wait_type, wait_reason, processor_mode,
|
||||
|
@ -937,7 +937,7 @@ dword_result_t NtSignalAndWaitForSingleObjectEx(dword_t signal_handle,
|
|||
auto wait_object =
|
||||
kernel_state()->object_table()->LookupObject<XObject>(wait_handle);
|
||||
if (signal_object && wait_object) {
|
||||
uint64_t timeout = timeout_ptr ? *timeout_ptr : 0;
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint32_t>(*timeout_ptr) : 0u;
|
||||
result =
|
||||
XObject::SignalAndWait(signal_object.get(), wait_object.get(), 3, 1,
|
||||
alertable, timeout_ptr ? &timeout : nullptr);
|
||||
|
|
|
@ -64,7 +64,7 @@ class XStaticEnumerator : public XEnumerator {
|
|||
std::memcpy(buffer, buffer_.data(), item_count_ * item_size_);
|
||||
}
|
||||
|
||||
bool WriteItem(uint8_t* buffer) {
|
||||
bool WriteItem(uint8_t* buffer) override {
|
||||
if (current_item_ >= item_count_) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -150,6 +150,8 @@ object_ref<XObject> XObject::Restore(KernelState* kernel_state, Type type,
|
|||
return XThread::Restore(kernel_state, stream);
|
||||
case kTypeTimer:
|
||||
break;
|
||||
case kTypeUndefined:
|
||||
break;
|
||||
}
|
||||
|
||||
assert_always("No restore handler exists for this object!");
|
||||
|
|
|
@ -1145,12 +1145,12 @@ object_ref<XThread> XThread::Restore(KernelState* kernel_state,
|
|||
thread->kernel_state_ = kernel_state;
|
||||
|
||||
if (!thread->RestoreObject(stream)) {
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (stream->Read<uint32_t>() != 'THRD') {
|
||||
XELOGE("Could not restore XThread - invalid magic!");
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
XELOGD("XThread %.8X", thread->handle());
|
||||
|
|
Loading…
Reference in New Issue