idmap2: fix clang-tidy warnings [readability-*]
Bug: 120024673
Test: mmm frameworks/base/cmds/idmap2; check output
Change-Id: I1565afac8d34e4347d8c946228d1134211e8b435
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp
index 86b00f1..7b16093 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.cpp
+++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp
@@ -39,10 +39,11 @@
using android::idmap2::BinaryStreamVisitor;
using android::idmap2::Idmap;
using android::idmap2::IdmapHeader;
+using android::idmap2::utils::kIdmapFilePermissionMask;
namespace {
-static constexpr const char* kIdmapCacheDir = "/data/resource-cache";
+constexpr const char* kIdmapCacheDir = "/data/resource-cache";
Status ok() {
return Status::ok();
@@ -69,13 +70,12 @@
int32_t user_id ATTRIBUTE_UNUSED, bool* _aidl_return) {
assert(_aidl_return);
const std::string idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_apk_path);
- if (unlink(idmap_path.c_str()) == 0) {
- *_aidl_return = true;
- return ok();
- } else {
+ if (unlink(idmap_path.c_str()) != 0) {
*_aidl_return = false;
return error("failed to unlink " + idmap_path + ": " + strerror(errno));
}
+ *_aidl_return = true;
+ return ok();
}
Status Idmap2Service::verifyIdmap(const std::string& overlay_apk_path,
@@ -119,7 +119,7 @@
return error(err.str());
}
- umask(0133); // u=rw,g=r,o=r
+ umask(kIdmapFilePermissionMask);
const std::string idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_apk_path);
std::ofstream fout(idmap_path);
if (fout.fail()) {