kern: build with -Wextra

This commit is contained in:
Michael Scire 2020-08-17 14:20:24 -07:00
parent d3014f6ed9
commit 73798cb812
32 changed files with 100 additions and 30 deletions

View file

@ -37,6 +37,7 @@ namespace ams::kern::arch::arm64::cpu {
constexpr KThreadTerminationInterruptHandler() : KInterruptHandler() { /* ... */ }
virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override {
MESOSPHERE_UNUSED(interrupt_id);
return nullptr;
}
};
@ -68,6 +69,8 @@ namespace ams::kern::arch::arm64::cpu {
/* Nintendo misuses this per their own API, but it's functional. */
virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override {
MESOSPHERE_UNUSED(interrupt_id);
if (this->which < 0) {
this->counter = cpu::GetCycleCounter();
} else {
@ -145,6 +148,7 @@ namespace ams::kern::arch::arm64::cpu {
}
virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override {
MESOSPHERE_UNUSED(interrupt_id);
this->ProcessOperation();
return nullptr;
}

View file

@ -24,6 +24,7 @@ namespace ams::kern::arch::arm64 {
constexpr KHardwareTimerInterruptTask() : KInterruptTask() { /* ... */ }
virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override {
MESOSPHERE_UNUSED(interrupt_id);
return this;
}

View file

@ -160,6 +160,7 @@ namespace ams::kern::arch::arm64 {
void KPageTable::Initialize(s32 core_id) {
/* Nothing actually needed here. */
MESOSPHERE_UNUSED(core_id);
}
Result KPageTable::InitializeForKernel(void *table, KVirtualAddress start, KVirtualAddress end) {
@ -181,7 +182,8 @@ namespace ams::kern::arch::arm64 {
}
Result KPageTable::InitializeForProcess(u32 id, ams::svc::CreateProcessFlag as_type, bool enable_aslr, bool from_back, KMemoryManager::Pool pool, KProcessAddress code_address, size_t code_size, KMemoryBlockSlabManager *mem_block_slab_manager, KBlockInfoManager *block_info_manager, KPageTableManager *pt_manager) {
/* Convert the address space type to a width. */
/* The input ID isn't actually used. */
MESOSPHERE_UNUSED(id);
/* Get an ASID */
this->asid = g_asid_manager.Reserve();
@ -364,6 +366,9 @@ namespace ams::kern::arch::arm64 {
MESOSPHERE_ASSERT(util::IsAligned(GetInteger(phys_addr), L1BlockSize));
MESOSPHERE_ASSERT(util::IsAligned(num_pages * PageSize, L1BlockSize));
/* Allocation is never needed for L1 block mapping. */
MESOSPHERE_UNUSED(page_list, reuse_ll);
auto &impl = this->GetImpl();
/* Iterate, mapping each block. */

View file

@ -281,6 +281,7 @@ namespace ams::kern::arch::arm64 {
}
void KThreadContext::OnThreadTerminating(const KThread *thread) {
MESOSPHERE_UNUSED(thread);
/* ... */
}

View file

@ -498,6 +498,8 @@ namespace ams::kern {
R_TRY(PutUserString(user_str, len));
}
#else
MESOSPHERE_UNUSED(user_str, len);
#endif
return ResultSuccess();

View file

@ -62,7 +62,7 @@ namespace ams::kern {
/* Allocate memory for the process. */
auto &mm = Kernel::GetMemoryManager();
const auto pool = static_cast<KMemoryManager::Pool>(reader.UsesSecureMemory() ? KMemoryManager::Pool_System : KSystemControl::GetInitialProcessBinaryPool());
const auto pool = reader.UsesSecureMemory() ? KMemoryManager::Pool_System : static_cast<KMemoryManager::Pool>(KSystemControl::GetInitialProcessBinaryPool());
MESOSPHERE_R_ABORT_UNLESS(mm.Allocate(std::addressof(pg), params.code_num_pages, KMemoryManager::EncodeOption(pool, KMemoryManager::Direction_FromFront)));
{

View file

@ -157,6 +157,7 @@ namespace ams::kern {
case RegionType::OnMemoryBootImage:
case RegionType::DTB:
R_TRY(page_table->MapRegion(MemoryRegions[static_cast<u32>(type)], perm));
break;
default:
return svc::ResultNotFound();
}

View file

@ -86,6 +86,10 @@ namespace ams::kern {
/* Manager thread functions. */
void DpcManagerNormalThreadFunction(uintptr_t arg) {
/* Input argument goes unused. */
MESOSPHERE_UNUSED(arg);
/* Forever wait and service requests. */
while (true) {
KDpcTask::WaitForRequest();
KDpcTask::HandleRequest();
@ -93,6 +97,10 @@ namespace ams::kern {
}
void DpcManagerPreemptionThreadFunction(uintptr_t arg) {
/* Input argument goes unused. */
MESOSPHERE_UNUSED(arg);
/* Forever wait and service requests, rotating the scheduled queue every 10 ms. */
s64 timeout = KHardwareTimer::GetTick() + DpcManagerTimeout;
while (true) {
if (KDpcTask::TimedWaitForRequest(timeout)) {

View file

@ -128,7 +128,7 @@ namespace ams::kern {
KInterruptTask *KInterruptEventTask::OnInterrupt(s32 interrupt_id) {
MESOSPHERE_ASSERT_THIS();
MESOSPHERE_UNUSED(interrupt_id);
return this;
}

View file

@ -188,6 +188,10 @@ namespace ams::kern {
}
void SetupCoreLocalRegionMemoryRegions(KInitialPageTable &page_table, KInitialPageAllocator &page_allocator) {
/* NOTE: Nintendo passes page table here to use num_l1_entries; we don't use this at present. */
MESOSPHERE_UNUSED(page_table);
/* Get the virtual address of the core local reigon. */
const KVirtualAddress core_local_virt_start = GetCoreLocalRegionVirtualAddress();
MESOSPHERE_INIT_ABORT_UNLESS(KMemoryLayout::GetVirtualMemoryRegionTree().Insert(GetInteger(core_local_virt_start), CoreLocalRegionSize, KMemoryRegionType_CoreLocal));

View file

@ -203,7 +203,6 @@ namespace ams::kern {
}
/* Only succeed if we allocated as many pages as we wanted. */
MESOSPHERE_ASSERT(num_pages >= 0);
R_UNLESS(num_pages == 0, svc::ResultOutOfMemory());
/* We succeeded! */

View file

@ -2761,9 +2761,12 @@ namespace ams::kern {
lk1.emplace(lock_1);
}
/* Check memory state. */
/* Check memory state for source. */
R_TRY(src_page_table.CheckMemoryStateContiguous(src_addr, size, src_state_mask, src_state, src_test_perm, src_test_perm, src_attr_mask | KMemoryAttribute_Uncached, src_attr));
/* Destination state is intentionally unchecked. */
MESOSPHERE_UNUSED(dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr);
/* Get implementations. */
auto &src_impl = src_page_table.GetImpl();
auto &dst_impl = dst_page_table.GetImpl();

View file

@ -493,6 +493,9 @@ namespace ams::kern {
/* Lock ourselves, to prevent concurrent access. */
KScopedLightLock lk(this->state_lock);
/* Address and size parameters aren't used. */
MESOSPHERE_UNUSED(address, size);
/* Try to find an existing info for the memory. */
KSharedMemoryInfo *info = nullptr;
for (auto it = this->shared_memory_list.begin(); it != this->shared_memory_list.end(); ++it) {
@ -524,6 +527,9 @@ namespace ams::kern {
/* Lock ourselves, to prevent concurrent access. */
KScopedLightLock lk(this->state_lock);
/* Address and size parameters aren't used. */
MESOSPHERE_UNUSED(address, size);
/* Find an existing info for the memory. */
KSharedMemoryInfo *info = nullptr;
auto it = this->shared_memory_list.begin();

View file

@ -28,6 +28,7 @@ namespace ams::kern {
constexpr KSchedulerInterruptTask() : KInterruptTask() { /* ... */ }
virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override {
MESOSPHERE_UNUSED(interrupt_id);
return GetDummyInterruptTask();
}

View file

@ -53,6 +53,10 @@ namespace ams::kern {
this->msg_buffer_end = dst_address + sizeof(u32) * out_offset;
this->msg_buffer_space_end = dst_address + msg_size;
/* NOTE: Nintendo calculates the receive list index here using the special header. */
/* We pre-calculate it in the caller, and pass it as a parameter. */
MESOSPHERE_UNUSED(dst_special_header);
const u32 *recv_list = dst_msg + dst_recv_list_idx;
const auto entry_count = GetEntryCount(dst_header);
@ -494,6 +498,9 @@ namespace ams::kern {
auto &dst_page_table = dst_process.GetPageTable();
auto &src_page_table = src_process.GetPageTable();
/* NOTE: Session is used only for debugging, and so may go unused. */
MESOSPHERE_UNUSED(session);
/* The receive list is initially not broken. */
recv_list_broken = false;
@ -711,7 +718,7 @@ namespace ams::kern {
return ResultSuccess();
}
ALWAYS_INLINE Result ProcessSendMessagePointerDescriptors(int &offset, int &pointer_key, KProcessPageTable &dst_page_table, KProcessPageTable &src_page_table, const ipc::MessageBuffer &dst_msg, const ipc::MessageBuffer &src_msg, const ReceiveList &dst_recv_list, bool dst_user) {
ALWAYS_INLINE Result ProcessSendMessagePointerDescriptors(int &offset, int &pointer_key, KProcessPageTable &dst_page_table, const ipc::MessageBuffer &dst_msg, const ipc::MessageBuffer &src_msg, const ReceiveList &dst_recv_list, bool dst_user) {
/* Get the offset at the start of processing. */
const int cur_offset = offset;
@ -758,6 +765,9 @@ namespace ams::kern {
auto &dst_page_table = dst_process.GetPageTable();
auto &src_page_table = src_process.GetPageTable();
/* NOTE: Session is used only for debugging, and so may go unused. */
MESOSPHERE_UNUSED(session);
/* Determine the message buffers. */
u32 *dst_msg_ptr, *src_msg_ptr;
bool dst_user, src_user;
@ -860,7 +870,7 @@ namespace ams::kern {
/* Process any pointer buffers. */
for (auto i = 0; i < src_header.GetPointerCount(); ++i) {
R_TRY(ProcessSendMessagePointerDescriptors(offset, pointer_key, dst_page_table, src_page_table, dst_msg, src_msg, dst_recv_list, dst_user && dst_header.GetReceiveListCount() == ipc::MessageBuffer::MessageHeader::ReceiveListCountType_ToMessageBuffer));
R_TRY(ProcessSendMessagePointerDescriptors(offset, pointer_key, dst_page_table, dst_msg, src_msg, dst_recv_list, dst_user && dst_header.GetReceiveListCount() == ipc::MessageBuffer::MessageHeader::ReceiveListCountType_ToMessageBuffer));
}
/* Clear any map alias buffers. */

View file

@ -99,6 +99,7 @@ namespace ams::kern {
Result KSharedMemory::Unmap(KProcessPageTable *table, KProcessAddress address, size_t size, KProcess *process) {
MESOSPHERE_ASSERT_THIS();
MESOSPHERE_UNUSED(process);
/* Validate the size. */
R_UNLESS(this->page_group.GetNumPages() == util::DivideUp(size, PageSize), svc::ResultInvalidSize());

View file

@ -126,6 +126,8 @@ namespace ams::kern {
MESOSPHERE_RELEASE_VLOG(format, vl);
MESOSPHERE_RELEASE_LOG("\n");
va_end(vl);
#else
MESOSPHERE_UNUSED(file, line, format);
#endif
StopSystem();

View file

@ -26,6 +26,10 @@ namespace ams::kern::svc {
{
/* TODO: Implement Kernel Debugging. */
}
#else
{
MESOSPHERE_UNUSED(kern_debug_type, arg0, arg1, arg2);
}
#endif
}
@ -47,6 +51,10 @@ namespace ams::kern::svc {
break;
}
}
#else
{
MESOSPHERE_UNUSED(kern_trace_state);
}
#endif
}