Snap for 10447354 from e094bef721948e46bda92d041fd5e9f4d6dbeafb to mainline-resolv-release

Change-Id: Id13de35c7aaafc934dac914c93ffcde7a11cfc37
diff --git a/incfs/Android.bp b/incfs/Android.bp
index e94cbd2..e179011 100644
--- a/incfs/Android.bp
+++ b/incfs/Android.bp
@@ -84,7 +84,7 @@
     target: {
         android: {
             static_libs: [
-                "com.android.sysprop.incremental",
+                "libcom.android.sysprop.incremental",
             ],
         },
     },
diff --git a/incfs/MountRegistry.cpp b/incfs/MountRegistry.cpp
index 4f16f73..376eaf2 100644
--- a/incfs/MountRegistry.cpp
+++ b/incfs/MountRegistry.cpp
@@ -355,7 +355,8 @@
             if (mount.backing.empty()) {
                 mount.backing = std::move(backingDir);
             } else if (mount.backing != backingDir) {
-                LOG(WARNING) << "[incfs] root '" << *mount.roots.begin()
+                LOG(WARNING) << "[incfs] root '"
+                             << (!mount.roots.empty() ? *mount.roots.begin() : "<unknown>")
                              << "' mounted in multiple places with different backing dirs, '"
                              << mount.backing << "' vs new '" << backingDir
                              << "'; updating to the new one";
diff --git a/incfs/incfs.cpp b/incfs/incfs.cpp
index e13cd81..29574c1 100644
--- a/incfs/incfs.cpp
+++ b/incfs/incfs.cpp
@@ -1611,7 +1611,8 @@
         }
         return isFullyLoadedV2(root, id);
     }
-    return isFullyLoadedSlow(openForSpecialOps(control->cmd, makeCommandPath(root, path).c_str()));
+    auto fd = ab::unique_fd(openForSpecialOps(control->cmd, makeCommandPath(root, path).c_str()));
+    return isFullyLoadedSlow(fd.get());
 }
 IncFsErrorCode IncFs_IsFullyLoadedById(const IncFsControl* control, IncFsFileId fileId) {
     if (!control) {
@@ -1624,9 +1625,10 @@
     if (features() & Features::v2) {
         return isFullyLoadedV2(root, fileId);
     }
-    return isFullyLoadedSlow(
+    auto fd = ab::unique_fd(
             openForSpecialOps(control->cmd,
                               makeCommandPath(root, indexPath(root, fileId)).c_str()));
+    return isFullyLoadedSlow(fd.get());
 }
 
 static IncFsErrorCode isEverythingLoadedV2(const IncFsControl* control) {
diff --git a/incfs/include/incfs_inline.h b/incfs/include/incfs_inline.h
index f3d1e89..545a735 100644
--- a/incfs/include/incfs_inline.h
+++ b/incfs/include/incfs_inline.h
@@ -306,9 +306,9 @@
 }
 
 inline std::pair<ErrorCode, FilledRanges> getFilledRanges(int fd, FilledRanges&& resumeFrom) {
+    auto totalRanges = resumeFrom.dataRanges().size() + resumeFrom.hashRanges().size();
     auto rawRanges = resumeFrom.internalRawRanges();
     auto buffer = resumeFrom.extractInternalBufferAndClear();
-    auto totalRanges = resumeFrom.dataRanges().size() + resumeFrom.hashRanges().size();
     auto remainingSpace = buffer.size() - totalRanges;
     const bool loadAll = remainingSpace == 0;
     int res;
diff --git a/incfs/tests/util/map_ptr_test.cpp b/incfs/tests/util/map_ptr_test.cpp
index c78d91d..f9c96aa 100644
--- a/incfs/tests/util/map_ptr_test.cpp
+++ b/incfs/tests/util/map_ptr_test.cpp
@@ -325,4 +325,4 @@
     auto p1 = map->data().offset(missing_page_start).convert<uint32_t>();
     ASSERT_FALSE(p1);
     ASSERT_SIGBUS(p1.value());
-}
\ No newline at end of file
+}