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

@@ -232,7 +232,8 @@ namespace ams::ncm {
auto fragment_count = CountContentExceptForMeta(reader, index);
/* Recalculate. */
return CalculateSizeImpl<InstallContentMetaHeader, InstallContentInfo>(this->GetExtendedHeaderSize(), fragment_count + 1, 0, this->GetExtendedDataSize(), false);
*out_size = CalculateSizeImpl<InstallContentMetaHeader, InstallContentInfo>(this->GetExtendedHeaderSize(), fragment_count + 1, 0, this->GetExtendedDataSize(), false);
return ResultSuccess();
}
void PackagedContentMetaReader::ConvertToContentMeta(void *dst, size_t size, const ContentInfo &meta) {

View File

@@ -526,6 +526,8 @@ namespace ams::ncm {
/* Traverse the placeholder base directory finding valid placeholder files. */
R_TRY(TraverseDirectory(placeholder_dir, placeholder_accessor.GetHierarchicalDirectoryDepth(), [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, const fs::DirectoryEntry &entry) -> Result {
AMS_UNUSED(current_path);
*should_continue = true;
*should_retry_dir_read = false;
@@ -559,6 +561,8 @@ namespace ams::ncm {
/* Traverse the content base directory finding all files. */
R_TRY(TraverseDirectory(path, depth, [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, const fs::DirectoryEntry &entry) -> Result {
AMS_UNUSED(current_path);
*should_continue = true;
*should_retry_dir_read = false;
@@ -898,6 +902,7 @@ namespace ams::ncm {
}
Result ContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) {
AMS_UNUSED(content_id, path);
return ncm::ResultInvalidOperation();
}

View File

@@ -19,30 +19,37 @@
namespace ams::ncm {
Result HostContentStorageImpl::GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) {
AMS_UNUSED(out);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
AMS_UNUSED(placeholder_id, content_id, size);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) {
AMS_UNUSED(placeholder_id);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) {
AMS_UNUSED(out, placeholder_id);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) {
AMS_UNUSED(placeholder_id, offset, data);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::Register(PlaceHolderId placeholder_id, ContentId content_id) {
AMS_UNUSED(placeholder_id, content_id);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::Delete(ContentId content_id) {
AMS_UNUSED(content_id);
return ncm::ResultNotSupported();
}
@@ -69,6 +76,7 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) {
AMS_UNUSED(out, placeholder_id);
return ncm::ResultNotSupported();
}
@@ -77,18 +85,22 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) {
AMS_UNUSED(out_count, out_buf);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::GetContentCount(sf::Out<s32> out_count) {
AMS_UNUSED(out_count);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) {
AMS_UNUSED(out_count, out_buf, offset);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) {
AMS_UNUSED(out_size, content_id);
return ncm::ResultInvalidOperation();
}
@@ -98,22 +110,27 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
AMS_UNUSED(placeholder_id, old_content_id, new_content_id);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
AMS_UNUSED(placeholder_id, size);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) {
AMS_UNUSED(buf, content_id, offset);
return ncm::ResultInvalidOperation();
}
Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
AMS_UNUSED(out_rights_id, placeholder_id);
return ncm::ResultNotSupported();
}
Result HostContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
AMS_UNUSED(out_rights_id, placeholder_id);
return ncm::ResultNotSupported();
}
@@ -133,7 +150,7 @@ namespace ams::ncm {
/* Get the content path. */
Path path;
R_TRY(this->registered_content->GetPath(std::addressof(path), content_id));
/* Acquire the rights id for the content. */
RightsId rights_id;
R_TRY_CATCH(GetRightsId(std::addressof(rights_id), path)) {
@@ -150,6 +167,7 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) {
AMS_UNUSED(content_id, offset, data);
return ncm::ResultNotSupported();
}
@@ -168,6 +186,7 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::GetSizeFromPlaceHolderId(sf::Out<s64> out, PlaceHolderId placeholder_id) {
AMS_UNUSED(out, placeholder_id);
return ncm::ResultNotSupported();
}
@@ -176,6 +195,7 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id);
return ncm::ResultNotSupported();
}

View File

@@ -88,6 +88,7 @@ namespace ams::ncm {
}
Result OnMemoryContentMetaDatabaseImpl::LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) {
AMS_UNUSED(out_orphaned, content_ids);
return ResultInvalidContentMetaDatabase();
}

View File

@@ -27,6 +27,7 @@ namespace ams::ncm {
}
Result PackageInstallTask::GetInstallContentMetaInfo(InstallContentMetaInfo *out_info, const ContentMetaKey &key) {
AMS_UNUSED(out_info, key);
return ncm::ResultContentNotFound();
}
@@ -41,7 +42,7 @@ namespace ams::ncm {
s64 count;
fs::DirectoryEntry entry;
R_TRY(fs::ReadDirectory(std::addressof(count), std::addressof(entry), dir, 1));
/* No more entries remain, we are done. */
if (count == 0) {
break;

View File

@@ -26,6 +26,9 @@ namespace ams::ncm {
}
Result PackageInstallTaskBase::OnWritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) {
AMS_UNUSED(key);
/* Get the file path. */
PackagePath path;
if (content_info->GetType() == ContentType::Meta) {
this->CreateContentMetaPath(std::addressof(path), content_info->GetId());
@@ -57,6 +60,8 @@ namespace ams::ncm {
}
Result PackageInstallTaskBase::InstallTicket(const fs::RightsId &rights_id, ContentMetaType meta_type) {
AMS_UNUSED(meta_type);
/* Read ticket from file. */
s64 ticket_size;
std::unique_ptr<char[]> ticket;

View File

@@ -61,30 +61,37 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) {
AMS_UNUSED(out);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
AMS_UNUSED(placeholder_id, content_id, size);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) {
AMS_UNUSED(placeholder_id);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) {
AMS_UNUSED(out, placeholder_id);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) {
AMS_UNUSED(placeholder_id, offset, data);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::Register(PlaceHolderId placeholder_id, ContentId content_id) {
AMS_UNUSED(placeholder_id, content_id);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::Delete(ContentId content_id) {
AMS_UNUSED(content_id);
return ncm::ResultNotSupported();
}
@@ -134,6 +141,7 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) {
AMS_UNUSED(out, placeholder_id);
return ncm::ResultNotSupported();
}
@@ -142,14 +150,17 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) {
AMS_UNUSED(out_count, out_buf);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::GetContentCount(sf::Out<s32> out_count) {
AMS_UNUSED(out_count);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) {
AMS_UNUSED(out_count, out_buf, offset);
return ncm::ResultNotSupported();
}
@@ -175,10 +186,12 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
AMS_UNUSED(placeholder_id, old_content_id, new_content_id);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
AMS_UNUSED(placeholder_id, size);
return ncm::ResultNotSupported();
}
@@ -199,10 +212,12 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
AMS_UNUSED(out_rights_id, placeholder_id);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
AMS_UNUSED(out_rights_id, placeholder_id);
return ncm::ResultNotSupported();
}
@@ -232,6 +247,7 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) {
AMS_UNUSED(content_id, offset, data);
return ncm::ResultNotSupported();
}
@@ -250,6 +266,7 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::GetSizeFromPlaceHolderId(sf::Out<s64> out, PlaceHolderId placeholder_id) {
AMS_UNUSED(out, placeholder_id);
return ncm::ResultNotSupported();
}
@@ -258,10 +275,12 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id);
return ncm::ResultNotSupported();
}
Result ReadOnlyContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) {
AMS_UNUSED(content_id, path);
return ncm::ResultInvalidOperation();
}

View File

@@ -95,6 +95,7 @@ namespace ams::ncm {
Result GetMemoryReport(sf::Out<MemoryReport> out) {
/* TODO: libnx bindings */
AMS_UNUSED(out);
AMS_ABORT();
}
};

View File

@@ -158,11 +158,13 @@ namespace ams::ncm {
Result GetCount(sf::Out<u32> out_count) {
/* TODO: libnx bindings */
AMS_UNUSED(out_count);
AMS_ABORT();
}
Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) {
/* TODO: libnx bindings */
AMS_UNUSED(out_id, key);
AMS_ABORT();
}
};

View File

@@ -45,6 +45,16 @@ namespace ams::ncm {
static_assert(sizeof(ContentId) == sizeof(::NcmContentId));
return reinterpret_cast<::NcmContentId *>(std::addressof(c));
}
ALWAYS_INLINE const ::NcmContentId *Convert(const ContentId *c) {
static_assert(sizeof(ContentId) == sizeof(::NcmContentId));
return reinterpret_cast<const ::NcmContentId *>(c);
}
ALWAYS_INLINE const ::NcmContentId *Convert(const ContentId &c) {
static_assert(sizeof(ContentId) == sizeof(::NcmContentId));
return reinterpret_cast<const ::NcmContentId *>(std::addressof(c));
}
public:
Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) {
return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer()));
@@ -191,11 +201,11 @@ namespace ams::ncm {
}
Result RegisterPath(const ContentId &content_id, const Path &path) {
AMS_ABORT("TODO");
return ncmContentStorageRegisterPath(std::addressof(this->srv), Convert(content_id), path.str);
}
Result ClearRegisteredPath() {
AMS_ABORT("TODO");
return ncmContentStorageClearRegisteredPath(std::addressof(this->srv));
}
};
static_assert(ncm::IsIContentStorage<RemoteContentStorageImpl>);