From a24e2c255173070c5e354f501bc28e4c7e8d77da Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Thu, 28 Nov 2024 15:22:05 +0000 Subject: 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 --- libnativeloader/native_loader_namespace.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libnativeloader/native_loader_namespace.cpp') 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::GetExportedNamespace(const // "system" for those in the Runtime APEX. Try "system" first since // "default" always exists. Result NativeLoaderNamespace::GetSystemNamespace(bool is_bridged) { - Result ns = GetExportedNamespace(kSystemNamespaceName, is_bridged); - if (ns.ok()) return ns; - ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged); - if (ns.ok()) return ns; + if (Result ns = GetExportedNamespace(kSystemNamespaceName, is_bridged); + ns.ok()) { + return ns; + } + if (Result 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. -- cgit v1.2.3-59-g8ed1b