libstrat: enable -Wextra, -Werror
This caught an embarrassingly large number of bugs.
This commit is contained in:
@@ -107,46 +107,57 @@ namespace ams::fs {
|
||||
}
|
||||
|
||||
virtual Result DoCreateFile(const char *path, s64 size, int flags) override final {
|
||||
AMS_UNUSED(path, size, flags);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoDeleteFile(const char *path) override final {
|
||||
AMS_UNUSED(path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoCreateDirectory(const char *path) override final {
|
||||
AMS_UNUSED(path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoDeleteDirectory(const char *path) override final {
|
||||
AMS_UNUSED(path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoDeleteDirectoryRecursively(const char *path) override final {
|
||||
AMS_UNUSED(path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoRenameFile(const char *old_path, const char *new_path) override final {
|
||||
AMS_UNUSED(old_path, new_path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override final {
|
||||
AMS_UNUSED(old_path, new_path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoCleanDirectoryRecursively(const char *path) override final {
|
||||
AMS_UNUSED(path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA();
|
||||
}
|
||||
|
||||
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override final {
|
||||
AMS_UNUSED(out, path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateB();
|
||||
}
|
||||
|
||||
virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override final {
|
||||
AMS_UNUSED(out, path);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateB();
|
||||
}
|
||||
|
||||
virtual Result DoCommitProvisionally(s64 counter) override final {
|
||||
AMS_UNUSED(counter);
|
||||
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateC();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace ams::fssystem::buffers {
|
||||
R_CATCH(fs::ResultBufferAllocationFailed) {
|
||||
if ((1 <= count && count <= BufferAllocationRetryLogCountMax) || ((count % BufferAllocationRetryLogInterval) == 0)) {
|
||||
/* TODO: Log */
|
||||
AMS_UNUSED(function_name);
|
||||
}
|
||||
R_TRY(on_failure());
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace ams::fssystem {
|
||||
template<typename T>
|
||||
class StdAllocator : public std::allocator<T> {
|
||||
public:
|
||||
StdAllocator() { /* ... */ }
|
||||
StdAllocator(const StdAllocator &) { /* ... */ }
|
||||
StdAllocator() = default;
|
||||
StdAllocator(const StdAllocator &) = default;
|
||||
template<class U>
|
||||
StdAllocator(const StdAllocator<U> &) { /* ... */ }
|
||||
StdAllocator(const StdAllocator<U> &) : std::allocator<T>() { /* ... */ };
|
||||
|
||||
template<typename U>
|
||||
struct rebind {
|
||||
@@ -40,6 +40,7 @@ namespace ams::fssystem {
|
||||
};
|
||||
|
||||
T *Allocate(size_t size, const T *hint = nullptr) {
|
||||
AMS_UNUSED(hint);
|
||||
return static_cast<T *>(::ams::fssystem::Allocate(sizeof(T) * size));
|
||||
}
|
||||
|
||||
|
||||
@@ -292,13 +292,17 @@ namespace ams::sf::hipc {
|
||||
}
|
||||
protected:
|
||||
virtual ServerSession *AllocateSession() override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (!this->session_allocated[i]) {
|
||||
this->session_allocated[i] = true;
|
||||
return GetPointer(this->session_storages[i]);
|
||||
if constexpr (MaxSessions > 0) {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (!this->session_allocated[i]) {
|
||||
this->session_allocated[i] = true;
|
||||
return GetPointer(this->session_storages[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -310,13 +314,17 @@ namespace ams::sf::hipc {
|
||||
}
|
||||
|
||||
virtual Server *AllocateServer() override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
for (size_t i = 0; i < MaxServers; i++) {
|
||||
if (!this->server_allocated[i]) {
|
||||
this->server_allocated[i] = true;
|
||||
return GetPointer(this->server_storages[i]);
|
||||
if constexpr (MaxServers > 0) {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
|
||||
for (size_t i = 0; i < MaxServers; i++) {
|
||||
if (!this->server_allocated[i]) {
|
||||
this->server_allocated[i] = true;
|
||||
return GetPointer(this->server_storages[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -390,16 +398,20 @@ namespace ams::sf::hipc {
|
||||
|
||||
~ServerManager() {
|
||||
/* Close all sessions. */
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (this->session_allocated[i]) {
|
||||
this->CloseSessionImpl(GetPointer(this->session_storages[i]));
|
||||
if constexpr (MaxSessions > 0) {
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (this->session_allocated[i]) {
|
||||
this->CloseSessionImpl(GetPointer(this->session_storages[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Close all servers. */
|
||||
for (size_t i = 0; i < MaxServers; i++) {
|
||||
if (this->server_allocated[i]) {
|
||||
this->DestroyServer(GetPointer(this->server_storages[i]));
|
||||
if constexpr (MaxServers > 0) {
|
||||
for (size_t i = 0; i < MaxServers; i++) {
|
||||
if (this->server_allocated[i]) {
|
||||
this->DestroyServer(GetPointer(this->server_storages[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,6 +835,8 @@ namespace ams::sf::impl {
|
||||
}
|
||||
|
||||
virtual void SetOutObjects(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response, cmif::ServiceObjectHolder *out_objects, cmif::DomainObjectId *ids) override final {
|
||||
AMS_UNUSED(ids);
|
||||
|
||||
#define _SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(n) do { if constexpr (CommandMeta::NumOutObjects > n) { SetOutObjectImpl<n>(response, ctx.manager, std::move(out_objects[n])); } } while (0)
|
||||
_SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(0);
|
||||
_SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(1);
|
||||
|
||||
@@ -36,11 +36,13 @@ namespace ams::sf {
|
||||
|
||||
template<typename>
|
||||
static void *AllocateAligned(size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
return A().Allocate(size);
|
||||
}
|
||||
|
||||
template<typename>
|
||||
static void DeallocateAligned(void *ptr, size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
A().Deallocate(ptr, size);
|
||||
}
|
||||
};
|
||||
@@ -56,11 +58,13 @@ namespace ams::sf {
|
||||
|
||||
template<typename T>
|
||||
static void *AllocateAligned(size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
return StatelessAllocator<T>().Allocate(size);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void DeallocateAligned(void *ptr, size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
StatelessAllocator<T>().Deallocate(ptr, size);
|
||||
}
|
||||
};
|
||||
@@ -72,10 +76,12 @@ namespace ams::sf {
|
||||
using Allocator = A;
|
||||
|
||||
static void *AllocateAligned(Allocator *allocator, size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
return allocator->Allocate(size);
|
||||
}
|
||||
|
||||
static void DeallocateAligned(Allocator *allocator, void *ptr, size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
allocator->Deallocate(ptr, size);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,11 +34,13 @@ namespace ams::sf {
|
||||
public:
|
||||
void *Allocate(size_t size) {
|
||||
AMS_ASSERT(size == sizeof(T));
|
||||
AMS_UNUSED(size);
|
||||
return DefaultAllocateImpl(sizeof(Holder), alignof(Holder), offsetof(Holder, storage));
|
||||
}
|
||||
|
||||
void Deallocate(void *ptr, size_t size) {
|
||||
AMS_ASSERT(size == sizeof(T));
|
||||
AMS_UNUSED(size);
|
||||
return DefaultDeallocateImpl(ptr, sizeof(Holder), alignof(Holder), offsetof(Holder, storage));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace ams::sf {
|
||||
static void *operator new(size_t size);
|
||||
|
||||
static void operator delete(void *ptr, size_t size) {
|
||||
/* ... */
|
||||
AMS_UNUSED(ptr, size);
|
||||
}
|
||||
|
||||
static void *operator new(size_t size, Allocator *a) {
|
||||
|
||||
@@ -37,11 +37,13 @@ namespace ams::sf {
|
||||
|
||||
template<typename T>
|
||||
static void *AllocateAligned(size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
return StdAllocator<T>().allocate(size / sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void DeallocateAligned(void *ptr, size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
StdAllocator<T>().deallocate(static_cast<T *>(ptr), size / sizeof(T));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user