OSDN Git Service

Convert system/linkerconfig to Result::ok()
authorBernie Innocenti <codewiz@google.com>
Thu, 6 Feb 2020 14:16:23 +0000 (23:16 +0900)
committerBernie Innocenti <codewiz@google.com>
Thu, 6 Feb 2020 14:22:12 +0000 (23:22 +0900)
No functionality changes, this is a mechanical cleanup.

Test: m
Change-Id: I759398fdf01d1703b0c128fb4f34d33a6f1a2027

generator/librarylistloader.cc
generator/variableloader.cc
main.cc

index 33f552e..65aae1c 100644 (file)
@@ -66,7 +66,7 @@ namespace linkerconfig {
 namespace generator {
 std::string GetLibrariesString(std::string library_file_path) {
   auto library_list_result = GetLibrariesFromFile(library_file_path);
-  if (library_list_result) {
+  if (library_list_result.ok()) {
     return android::base::Join(*library_list_result, ':');
   } else {
     // Consider unavailable library file as empty
@@ -80,13 +80,13 @@ std::string GetPublicLibrariesString(std::string library_file_path,
   auto library_list = GetLibrariesFromFile(library_file_path);
   auto private_library_list = GetLibrariesFromFile(private_library_file_path);
 
-  if (!library_list) {
+  if (!library_list.ok()) {
     // Consider unavailable library file as empty
     LOG(WARNING) << library_list.error();
     return "";
   }
 
-  if (!private_library_list) {
+  if (!private_library_list.ok()) {
     // No private library found. All libraries are public
     LOG(WARNING) << private_library_list.error();
     return android::base::Join(*library_list, ':');
@@ -109,13 +109,13 @@ std::string GetPrivateLibrariesString(std::string library_file_path,
   auto library_list = GetLibrariesFromFile(library_file_path);
   auto private_library_list = GetLibrariesFromFile(private_library_file_path);
 
-  if (!library_list) {
+  if (!library_list.ok()) {
     // Consider unavailable library file as empty
     LOG(WARNING) << library_list.error();
     return "";
   }
 
-  if (!private_library_list) {
+  if (!private_library_list.ok()) {
     // No private library found. All libraries are public
     LOG(WARNING) << private_library_list.error();
     return "";
@@ -134,4 +134,4 @@ std::string GetPrivateLibrariesString(std::string library_file_path,
 }
 }  // namespace generator
 }  // namespace linkerconfig
-}  // namespace android
\ No newline at end of file
+}  // namespace android
index 4b92391..038f6b9 100644 (file)
@@ -91,7 +91,7 @@ Result<std::string> GetRealPath(std::string target_path) {
 void LoadVariableFromPartitionPath(std::string variable_name, std::string path) {
   auto real_path = GetRealPath(path);
 
-  if (real_path) {
+  if (real_path.ok()) {
     Variables::AddValue(variable_name, *real_path);
   } else {
     LOG(WARNING) << real_path.error();
diff --git a/main.cc b/main.cc
index 5a9091c..96cb254 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -205,7 +205,7 @@ Result<void> GenerateConfiguration(Configuration config, std::string dir_path,
   }
 
   auto write_config = WriteConfigurationToFile(config, file_path);
-  if (!write_config) {
+  if (!write_config.ok()) {
     return write_config;
   } else if (update_permission && file_path != "") {
     return UpdatePermission(file_path);
@@ -253,7 +253,7 @@ void GenerateApexConfigurations(Context& ctx, const std::string& dir_path) {
   for (auto const& apex_item : ctx.GetApexModules()) {
     if (apex_item.has_bin) {
       auto result = GenerateApexConfiguration(dir_path, ctx, apex_item);
-      if (!result) {
+      if (!result.ok()) {
         LOG(WARNING) << result.error();
       }
     }
@@ -261,7 +261,7 @@ void GenerateApexConfigurations(Context& ctx, const std::string& dir_path) {
 }
 
 void ExitOnFailure(Result<void> task) {
-  if (!task) {
+  if (!task.ok()) {
     LOG(FATAL) << task.error();
     exit(EXIT_FAILURE);
   }