strat: build sysmodules with -Wextra/-Werror

This commit is contained in:
Michael Scire
2021-10-06 23:22:54 -07:00
parent e8f1efd01b
commit 6a53726833
61 changed files with 433 additions and 217 deletions

View File

@@ -145,7 +145,7 @@ namespace ams::mitm {
}
/* Initialization implementation */
void InitializeThreadFunc(void *arg) {
void InitializeThreadFunc(void *) {
/* Wait for the SD card to be ready. */
cfg::WaitSdCardInitialized();

View File

@@ -104,18 +104,23 @@ void __appExit(void) {
}
void *__libnx_alloc(size_t size) {
AMS_UNUSED(size);
AMS_ABORT("__libnx_alloc was called");
}
void *__libnx_aligned_alloc(size_t alignment, size_t size) {
AMS_UNUSED(alignment, size);
AMS_ABORT("__libnx_aligned_alloc was called");
}
void __libnx_free(void *mem) {
AMS_UNUSED(mem);
AMS_ABORT("__libnx_free was called");
}
int main(int argc, char **argv) {
AMS_UNUSED(argc, argv);
/* Register "ams" port, use up its session. */
{
svc::Handle ams_port;

View File

@@ -34,7 +34,7 @@ namespace ams::mitm::bpc_ams {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Create bpc:ams. */
{
os::NativeHandle bpcams_h;

View File

@@ -56,7 +56,7 @@ namespace ams::mitm::bpc {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Wait until initialization is complete. */
mitm::WaitInitialized();

View File

@@ -64,7 +64,7 @@ namespace ams::mitm::socket::resolver {
os::ThreadType g_extra_threads[NumExtraThreads];
void LoopServerThread(void *arg) {
void LoopServerThread(void *) {
/* Loop forever, servicing our services. */
g_server_manager.LoopProcess();
}
@@ -114,7 +114,7 @@ namespace ams::mitm::socket::resolver {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Wait until initialization is complete. */
mitm::WaitInitialized();

View File

@@ -40,6 +40,8 @@ namespace ams::mitm::socket::resolver {
}
ssize_t SerializeRedirectedAddrInfo(u8 * const dst, size_t dst_size, const char *hostname, ams::socket::InAddrT redirect_addr, u16 redirect_port, const struct addrinfo *hint) {
AMS_UNUSED(hostname);
struct addrinfo ai = {
.ai_flags = 0,
.ai_family = AF_UNSPEC,
@@ -85,6 +87,8 @@ namespace ams::mitm::socket::resolver {
}
Result ResolverImpl::GetHostByNameRequest(u32 cancel_handle, const sf::ClientProcessId &client_pid, bool use_nsd_resolve, const sf::InBuffer &name, sf::Out<u32> out_host_error, sf::Out<u32> out_errno, const sf::OutBuffer &out_hostent, sf::Out<u32> out_size) {
AMS_UNUSED(cancel_handle, client_pid, use_nsd_resolve);
const char *hostname = reinterpret_cast<const char *>(name.GetPointer());
LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", this->client_info.program_id.value, hostname);
@@ -105,6 +109,8 @@ namespace ams::mitm::socket::resolver {
}
Result ResolverImpl::GetAddrInfoRequest(u32 cancel_handle, const sf::ClientProcessId &client_pid, bool use_nsd_resolve, const sf::InBuffer &node, const sf::InBuffer &srv, const sf::InBuffer &serialized_hint, const sf::OutBuffer &out_addrinfo, sf::Out<u32> out_errno, sf::Out<s32> out_retval, sf::Out<u32> out_size) {
AMS_UNUSED(cancel_handle, client_pid, use_nsd_resolve);
const char *hostname = reinterpret_cast<const char *>(node.GetPointer());
LogDebug("[%016lx]: GetAddrInfoRequest(%s, %s)\n", this->client_info.program_id.value, reinterpret_cast<const char *>(node.GetPointer()), reinterpret_cast<const char *>(srv.GetPointer()));
@@ -142,6 +148,8 @@ namespace ams::mitm::socket::resolver {
}
Result ResolverImpl::GetHostByNameRequestWithOptions(const sf::ClientProcessId &client_pid, const sf::InAutoSelectBuffer &name, const sf::OutAutoSelectBuffer &out_hostent, sf::Out<u32> out_size, u32 options_version, const sf::InAutoSelectBuffer &options, u32 num_options, sf::Out<s32> out_host_error, sf::Out<s32> out_errno) {
AMS_UNUSED(client_pid, options_version, options, num_options);
const char *hostname = reinterpret_cast<const char *>(name.GetPointer());
LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", this->client_info.program_id.value, hostname);
@@ -162,6 +170,8 @@ namespace ams::mitm::socket::resolver {
}
Result ResolverImpl::GetAddrInfoRequestWithOptions(const sf::ClientProcessId &client_pid, const sf::InBuffer &node, const sf::InBuffer &srv, const sf::InBuffer &serialized_hint, const sf::OutAutoSelectBuffer &out_addrinfo, sf::Out<u32> out_size, sf::Out<s32> out_retval, u32 options_version, const sf::InAutoSelectBuffer &options, u32 num_options, sf::Out<s32> out_host_error, sf::Out<s32> out_errno) {
AMS_UNUSED(client_pid, options_version, options, num_options);
const char *hostname = reinterpret_cast<const char *>(node.GetPointer());
LogDebug("[%016lx]: GetAddrInfoRequestWithOptions(%s, %s)\n", this->client_info.program_id.value, hostname, reinterpret_cast<const char *>(srv.GetPointer()));

View File

@@ -35,6 +35,7 @@ namespace ams::mitm::socket::resolver {
/* We will mitm:
* - everything.
*/
AMS_UNUSED(client_info);
return true;
}
public:

View File

@@ -20,6 +20,9 @@
namespace ams::mitm::socket::resolver::serializer {
ssize_t DNSSerializer::CheckToBufferArguments(const u8 *dst, size_t dst_size, size_t required, int error_id) {
/* TODO: Logging, using error_id */
AMS_UNUSED(error_id);
if (dst == nullptr) {
return -1;
} else if (dst_size < required) {

View File

@@ -26,7 +26,7 @@ namespace ams::mitm::socket::resolver::serializer {
concept IsInAddr = std::same_as<T, ams::socket::InAddr> || std::same_as<T, struct in_addr>;
template<typename T> requires IsInAddr<T>
size_t SizeOfImpl(const T &in) {
size_t SizeOfImpl(const T &) {
return sizeof(u32);
}

View File

@@ -99,7 +99,7 @@ namespace ams::mitm::fs {
return sf::CreateSharedObjectEmplaced<ams::fssrv::sf::IStorage, ams::fssrv::impl::StorageInterfaceAdapter>(std::forward<Arguments>(args)...);
}
Result OpenHblWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId client_program_id, ncm::ProgramId program_id, FsFileSystemType filesystem_type) {
Result OpenHblWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id) {
/* Verify eligibility. */
bool is_hbl;
R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession());
@@ -122,7 +122,7 @@ namespace ams::mitm::fs {
return ResultSuccess();
}
Result OpenProgramSpecificWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId client_program_id, ncm::ProgramId program_id, FsFileSystemType filesystem_type, Service *fwd, const fssrv::sf::Path *path, bool with_id) {
Result OpenProgramSpecificWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id, FsFileSystemType filesystem_type, Service *fwd, const fssrv::sf::Path *path, bool with_id) {
/* Directory must exist. */
{
FsDir d;
@@ -174,13 +174,13 @@ namespace ams::mitm::fs {
R_UNLESS(filesystem_type == FsFileSystemType_ContentManual, sm::mitm::ResultShouldForwardToSession());
/* Try to mount the HBL web filesystem. If this succeeds then we're done. */
R_UNLESS(R_FAILED(OpenHblWebContentFileSystem(out, client_program_id, program_id, filesystem_type)), ResultSuccess());
R_SUCCEED_IF(R_SUCCEEDED(OpenHblWebContentFileSystem(out, program_id)));
/* If program specific override shouldn't be attempted, fall back. */
R_UNLESS(try_program_specific, sm::mitm::ResultShouldForwardToSession());
/* If we're not opening a HBL filesystem, just try to open a generic one. */
return OpenProgramSpecificWebContentFileSystem(out, client_program_id, program_id, filesystem_type, fwd, path, with_id);
return OpenProgramSpecificWebContentFileSystem(out, program_id, filesystem_type, fwd, path, with_id);
}
}

View File

@@ -28,7 +28,7 @@ namespace ams::mitm::fs {
os::MessageQueue g_req_mq(g_mq_storage + 0, 1);
os::MessageQueue g_ack_mq(g_mq_storage + 1, 1);
void RomfsInitializerThreadFunction(void *arg) {
void RomfsInitializerThreadFunction(void *) {
while (true) {
uintptr_t storage_uptr = 0;
g_req_mq.Receive(&storage_uptr);
@@ -100,7 +100,6 @@ namespace ams::mitm::fs {
Result LayeredRomfsStorage::Read(s64 offset, void *buffer, size_t size) {
/* Check if we can succeed immediately. */
R_UNLESS(size >= 0, fs::ResultInvalidSize());
R_SUCCEED_IF(size == 0);
/* Ensure we're initialized. */
@@ -112,8 +111,8 @@ namespace ams::mitm::fs {
const s64 virt_size = this->GetSize();
R_UNLESS(offset >= 0, fs::ResultInvalidOffset());
R_UNLESS(offset < virt_size, fs::ResultInvalidOffset());
if (size_t(virt_size - offset) < size) {
size = size_t(virt_size - offset);
if (static_cast<size_t>(virt_size - offset) < size) {
size = static_cast<size_t>(virt_size - offset);
}
/* Find first source info via binary search. */
@@ -130,7 +129,7 @@ namespace ams::mitm::fs {
if (offset < cur_source.virtual_offset + cur_source.size) {
const s64 offset_within_source = offset - cur_source.virtual_offset;
const size_t cur_read_size = std::min(size - read_so_far, size_t(cur_source.size - offset_within_source));
const size_t cur_read_size = std::min(size - read_so_far, static_cast<size_t>(cur_source.size - offset_within_source));
switch (cur_source.source_type) {
case romfs::DataSourceType::Storage:
R_ABORT_UNLESS(this->storage_romfs->Read(cur_source.storage_source_info.offset + offset_within_source, cur_dst, cur_read_size));
@@ -167,7 +166,7 @@ namespace ams::mitm::fs {
} else {
/* Explicitly handle padding. */
const auto &next_source = *(++it);
const size_t padding_size = size_t(next_source.virtual_offset - offset);
const size_t padding_size = static_cast<size_t>(next_source.virtual_offset - offset);
std::memset(cur_dst, 0, padding_size);
read_so_far += padding_size;
@@ -194,6 +193,8 @@ namespace ams::mitm::fs {
}
Result LayeredRomfsStorage::OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) {
AMS_UNUSED(offset, src, src_size);
switch (op_id) {
case OperationId::Invalidate:
case OperationId::QueryRange:

View File

@@ -52,11 +52,13 @@ namespace ams::mitm::fs {
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
/* TODO: Better result code? */
AMS_UNUSED(offset, buffer, size);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result SetSize(s64 size) override {
/* TODO: Better result code? */
AMS_UNUSED(size);
return ams::fs::ResultUnsupportedOperation();
}
};

View File

@@ -64,7 +64,7 @@ namespace ams::mitm::fs {
os::ThreadType g_extra_threads[NumExtraThreads];
void LoopServerThread(void *arg) {
void LoopServerThread(void *) {
/* Loop forever, servicing our services. */
g_server_manager.LoopProcess();
}
@@ -98,7 +98,7 @@ namespace ams::mitm::fs {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Create fs mitm. */
R_ABORT_UNLESS((g_server_manager.RegisterMitmServer<FsMitmService>(PortIndex_Mitm, MitmServiceName)));

View File

@@ -28,45 +28,52 @@ namespace ams::mitm::fs {
virtual ~ReadOnlyLayeredFileSystem() { /* ... */ }
private:
virtual Result DoCreateFile(const char *path, s64 size, int flags) override final {
AMS_UNUSED(path, size, flags);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoDeleteFile(const char *path) override final {
AMS_UNUSED(path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoCreateDirectory(const char *path) override final {
AMS_UNUSED(path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoDeleteDirectory(const char *path) override final {
AMS_UNUSED(path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoDeleteDirectoryRecursively(const char *path) override final {
AMS_UNUSED(path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoRenameFile(const char *old_path, const char *new_path) override final {
AMS_UNUSED(old_path, new_path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override final {
AMS_UNUSED(old_path, new_path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoGetEntryType(ams::fs::DirectoryEntryType *out, const char *path) override final {
R_UNLESS(R_FAILED(this->fs_1.GetEntryType(out, path)), ResultSuccess());
R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.GetEntryType(out, path)));
return this->fs_2.GetEntryType(out, path);
}
virtual Result DoOpenFile(std::unique_ptr<ams::fs::fsa::IFile> *out_file, const char *path, ams::fs::OpenMode mode) override final {
R_UNLESS(R_FAILED(this->fs_1.OpenFile(out_file, path, mode)), ResultSuccess());
R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.OpenFile(out_file, path, mode)));
return this->fs_2.OpenFile(out_file, path, mode);
}
virtual Result DoOpenDirectory(std::unique_ptr<ams::fs::fsa::IDirectory> *out_dir, const char *path, ams::fs::OpenDirectoryMode mode) override final {
R_UNLESS(R_FAILED(this->fs_1.OpenDirectory(out_dir, path, mode)), ResultSuccess());
R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.OpenDirectory(out_dir, path, mode)));
return this->fs_2.OpenDirectory(out_dir, path, mode);
}
@@ -75,19 +82,22 @@ namespace ams::mitm::fs {
}
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) {
AMS_UNUSED(out, path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) {
AMS_UNUSED(out, path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoCleanDirectoryRecursively(const char *path) {
AMS_UNUSED(path);
return ams::fs::ResultUnsupportedOperation();
}
virtual Result DoGetFileTimeStampRaw(ams::fs::FileTimeStampRaw *out, const char *path) {
R_UNLESS(R_FAILED(this->fs_1.GetFileTimeStampRaw(out, path)), ResultSuccess());
R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.GetFileTimeStampRaw(out, path)));
return this->fs_2.GetFileTimeStampRaw(out, path);
}
};

View File

@@ -61,7 +61,7 @@ namespace ams::mitm::ns {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Wait until initialization is complete. */
mitm::WaitInitialized();

View File

@@ -64,7 +64,7 @@ namespace ams::mitm::settings {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Wait until initialization is complete. */
mitm::WaitInitialized();

View File

@@ -35,6 +35,7 @@ namespace ams::mitm::settings {
/* We will mitm:
* - everything, because we want to intercept all settings requests.
*/
AMS_UNUSED(client_info);
return true;
}
public:

View File

@@ -45,7 +45,7 @@ namespace ams::mitm::sysupdater {
}
void MitmModule::ThreadFunction(void *arg) {
void MitmModule::ThreadFunction(void *) {
/* Wait until initialization is complete. */
mitm::WaitInitialized();