diff options
author | 2024-11-28 15:22:05 +0000 | |
---|---|---|
committer | 2024-11-28 20:11:17 +0000 | |
commit | a24e2c255173070c5e354f501bc28e4c7e8d77da (patch) | |
tree | 88c9d931a25ecc8a0cc924d18b393c44fecdc983 /libnativeloader/native_loader_namespace.cpp | |
parent | cca3341e67fd9f45362448428abd47da09cdb954 (diff) |
Make NativeLoaderNamespace instances immutable.
To make it easier to reason about thread safety.
Test: atest libnativeloader_e2e_tests libnativeloader_test \
art_libnativeloader_cts_test libnativeloader_lazy_test
Bug: 326505705
Bug: 326610154
Change-Id: I2447ed8120625823d3298d392d22828af2c22402
Diffstat (limited to 'libnativeloader/native_loader_namespace.cpp')
-rw-r--r-- | libnativeloader/native_loader_namespace.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libnativeloader/native_loader_namespace.cpp b/libnativeloader/native_loader_namespace.cpp index cfb84b7d9e..98236064d0 100644 --- a/libnativeloader/native_loader_namespace.cpp +++ b/libnativeloader/native_loader_namespace.cpp @@ -69,10 +69,14 @@ Result<NativeLoaderNamespace> NativeLoaderNamespace::GetExportedNamespace(const // "system" for those in the Runtime APEX. Try "system" first since // "default" always exists. Result<NativeLoaderNamespace> NativeLoaderNamespace::GetSystemNamespace(bool is_bridged) { - Result<NativeLoaderNamespace> ns = GetExportedNamespace(kSystemNamespaceName, is_bridged); - if (ns.ok()) return ns; - ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged); - if (ns.ok()) return ns; + if (Result<NativeLoaderNamespace> ns = GetExportedNamespace(kSystemNamespaceName, is_bridged); + ns.ok()) { + return ns; + } + if (Result<NativeLoaderNamespace> ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged); + ns.ok()) { + return ns; + } // If nothing is found, return NativeLoaderNamespace constructed from nullptr. // nullptr also means default namespace to the linker. |