libstrat: enable -Wextra, -Werror

This caught an embarrassingly large number of bugs.
This commit is contained in:
Michael Scire
2021-10-06 15:20:48 -07:00
parent e1fbf27398
commit 7ca83c9d3b
160 changed files with 691 additions and 152 deletions

View File

@@ -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]));
}
}
}
}

View File

@@ -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);

View File

@@ -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);
}
};

View File

@@ -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));
}
};

View File

@@ -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) {

View File

@@ -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));
}
};