Merge "fs_mgr: fix SIGSEGV when ostream << nullptr" am: 225f0d98c8 am: 9af4b13b8f am: 942b4efa2e
am: 63d224a2bc
Change-Id: I2798cd3e57b89a5a8b48d72d62f00b749cc690d9
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 94733c4..c189eee 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -965,16 +965,20 @@
should_use_metadata_encryption(&fstab->recs[attempted_idx])) {
encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
} else {
+ // fs_options might be null so we cannot use PERROR << directly.
+ // Use StringPrintf to output "(null)" instead.
if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
- PERROR << "Ignoring failure to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Ignoring failure to mount an un-encryptable or wiped "
+ "partition on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
} else {
- PERROR << "Failed to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Failed to mount an un-encryptable or wiped partition "
+ "on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
++error_count;
}
continue;