diff options
author | Bernie Innocenti <codewiz@google.com> | 2020-12-19 15:31:52 +0900 |
---|---|---|
committer | Bernie Innocenti <codewiz@google.com> | 2020-12-21 15:50:57 +0000 |
commit | 58cf8e3ffa23752f4e8e38cab4d89f9b44f9e57a (patch) | |
tree | 3cc4048865054e95a9bf72a5a50fe19c8e849c29 /libs | |
parent | 96db3dad2a4a1c4f1622a2b268b347cda0e808db (diff) |
Add explicit Result::ok() checks where needed
Test: m checkbuild continuous_instrumentation_tests continuous_instrumentation_tests_api_coverage continuous_native_tests device-tests platform_tests
Exempt-From-Owner-Approval: mechanical mass refactoring
Change-Id: I3117833c51cdb333cccdfd159d1582f2adef77db
Diffstat (limited to 'libs')
-rw-r--r-- | libs/androidfw/AssetManager2.cpp | 2 | ||||
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 4 | ||||
-rw-r--r-- | libs/androidfw/ResourceUtils.cpp | 12 |
3 files changed, 11 insertions, 7 deletions
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp index a545b3d5e134..bec80a7d605e 100644 --- a/libs/androidfw/AssetManager2.cpp +++ b/libs/androidfw/AssetManager2.cpp @@ -670,7 +670,7 @@ base::expected<FindEntryResult, NullOrIOError> AssetManager2::FindEntryInternal( } auto entry_flags = type_spec->GetFlagsForEntryIndex(entry_idx); - if (UNLIKELY(!entry_flags)) { + if (UNLIKELY(!entry_flags.has_value())) { return base::unexpected(entry_flags.error()); } type_flags |= entry_flags.value(); diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 4010e4e10317..bce70e2aae9e 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -897,12 +897,12 @@ base::expected<StringPiece, NullOrIOError> ResStringPool::string8At(size_t idx) // Decode the UTF-16 length. This is not used if we're not // converting to UTF-16 from UTF-8. const base::expected<size_t, IOError> u16len = decodeLength(&str); - if (UNLIKELY(!u16len)) { + if (UNLIKELY(!u16len.has_value())) { return base::unexpected(u16len.error()); } const base::expected<size_t, IOError> u8len = decodeLength(&str); - if (UNLIKELY(!u8len)) { + if (UNLIKELY(!u8len.has_value())) { return base::unexpected(u8len.error()); } diff --git a/libs/androidfw/ResourceUtils.cpp b/libs/androidfw/ResourceUtils.cpp index a34aa7239250..87fb2c038c9f 100644 --- a/libs/androidfw/ResourceUtils.cpp +++ b/libs/androidfw/ResourceUtils.cpp @@ -56,7 +56,8 @@ base::expected<AssetManager2::ResourceName, NullOrIOError> ToResourceName( .package_len = package_name.size(), }; - if (base::expected<StringPiece, NullOrIOError> type_str = type_string_ref.string8()) { + if (base::expected<StringPiece, NullOrIOError> type_str = type_string_ref.string8(); + type_str.ok()) { name.type = type_str->data(); name.type_len = type_str->size(); } else if (UNLIKELY(IsIOError(type_str))) { @@ -64,7 +65,8 @@ base::expected<AssetManager2::ResourceName, NullOrIOError> ToResourceName( } if (name.type == nullptr) { - if (base::expected<StringPiece16, NullOrIOError> type16_str = type_string_ref.string16()) { + if (base::expected<StringPiece16, NullOrIOError> type16_str = type_string_ref.string16(); + type16_str.ok()) { name.type16 = type16_str->data(); name.type_len = type16_str->size(); } else if (!type16_str.has_value()) { @@ -72,7 +74,8 @@ base::expected<AssetManager2::ResourceName, NullOrIOError> ToResourceName( } } - if (base::expected<StringPiece, NullOrIOError> entry_str = entry_string_ref.string8()) { + if (base::expected<StringPiece, NullOrIOError> entry_str = entry_string_ref.string8(); + entry_str.ok()) { name.entry = entry_str->data(); name.entry_len = entry_str->size(); } else if (UNLIKELY(IsIOError(entry_str))) { @@ -80,7 +83,8 @@ base::expected<AssetManager2::ResourceName, NullOrIOError> ToResourceName( } if (name.entry == nullptr) { - if (base::expected<StringPiece16, NullOrIOError> entry16_str = entry_string_ref.string16()) { + if (base::expected<StringPiece16, NullOrIOError> entry16_str = entry_string_ref.string16(); + entry16_str.ok()) { name.entry16 = entry16_str->data(); name.entry_len = entry16_str->size(); } else if (!entry16_str.has_value()) { |