From 1195a6bd465872639c9a7b83518affc1b1fcf485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Tue, 11 May 2021 12:57:01 +0000 Subject: [PATCH] idmap2: fix cpplint warnings Bug: 189963636 Test: frameworks/base/cmds/idmap2/static-checks.sh Change-Id: I6da18cdbbd2fc33db711696445230a9f316dc143 --- cmds/idmap2/CPPLINT.cfg | 2 +- cmds/idmap2/idmap2/CommandUtils.cpp | 1 + cmds/idmap2/idmap2/CommandUtils.h | 8 +++++--- cmds/idmap2/idmap2/Create.cpp | 1 + cmds/idmap2/idmap2d/Idmap2Service.cpp | 2 ++ cmds/idmap2/idmap2d/Idmap2Service.h | 2 ++ cmds/idmap2/include/idmap2/FabricatedOverlay.h | 11 +++++++---- cmds/idmap2/include/idmap2/ResourceContainer.h | 7 ++++--- cmds/idmap2/libidmap2/FabricatedOverlay.cpp | 12 ++++++++---- cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp | 1 + cmds/idmap2/libidmap2/RawPrintVisitor.cpp | 2 ++ cmds/idmap2/libidmap2/ResourceContainer.cpp | 7 ++++++- cmds/idmap2/libidmap2/ResourceUtils.cpp | 1 + cmds/idmap2/tests/FabricatedOverlayTests.cpp | 3 ++- cmds/idmap2/tests/IdmapTests.cpp | 4 ++-- cmds/idmap2/tests/R.h | 4 ++-- 16 files changed, 47 insertions(+), 21 deletions(-) diff --git a/cmds/idmap2/CPPLINT.cfg b/cmds/idmap2/CPPLINT.cfg index 20ed43c2a76a9..eada694095d61 100644 --- a/cmds/idmap2/CPPLINT.cfg +++ b/cmds/idmap2/CPPLINT.cfg @@ -15,4 +15,4 @@ set noparent linelength=100 root=.. -filter=+build/include_alpha,-runtime/references,-build/c++ +filter=+build/include_alpha,-runtime/references,-build/c++,-build/include_alpha diff --git a/cmds/idmap2/idmap2/CommandUtils.cpp b/cmds/idmap2/idmap2/CommandUtils.cpp index bf30a76d581ae..63235ff7d1998 100644 --- a/cmds/idmap2/idmap2/CommandUtils.cpp +++ b/cmds/idmap2/idmap2/CommandUtils.cpp @@ -19,6 +19,7 @@ #include #include +#include "idmap2/CommandUtils.h" #include "idmap2/Idmap.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" diff --git a/cmds/idmap2/idmap2/CommandUtils.h b/cmds/idmap2/idmap2/CommandUtils.h index e06896784d6a3..341fec84ce9a5 100644 --- a/cmds/idmap2/idmap2/CommandUtils.h +++ b/cmds/idmap2/idmap2/CommandUtils.h @@ -14,8 +14,10 @@ * limitations under the License. */ -#ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_ -#define IDMAP2_IDMAP2_COMMAND_UTILS_H_ +#ifndef IDMAP2_IDMAP2_COMMANDUTILS_H_ +#define IDMAP2_IDMAP2_COMMANDUTILS_H_ + +#include #include "idmap2/PolicyUtils.h" #include "idmap2/Result.h" @@ -24,4 +26,4 @@ android::idmap2::Result Verify( const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, const std::string& overlay_name, PolicyBitmask fulfilled_policies, bool enforce_overlayable); -#endif // IDMAP2_IDMAP2_COMMAND_UTILS_H_ +#endif // IDMAP2_IDMAP2_COMMANDUTILS_H_ diff --git a/cmds/idmap2/idmap2/Create.cpp b/cmds/idmap2/idmap2/Create.cpp index 977a0bbadafb8..d5f1b895facf2 100644 --- a/cmds/idmap2/idmap2/Create.cpp +++ b/cmds/idmap2/idmap2/Create.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "androidfw/ResourceTypes.h" diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 73a7240219af8..2cfbac3f2c267 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h index 40843f75a3abb..c16c3c52155f6 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.h +++ b/cmds/idmap2/idmap2d/Idmap2Service.h @@ -24,7 +24,9 @@ #include #include +#include #include +#include namespace android::os { diff --git a/cmds/idmap2/include/idmap2/FabricatedOverlay.h b/cmds/idmap2/include/idmap2/FabricatedOverlay.h index be687d98081ea..375671881e5ff 100644 --- a/cmds/idmap2/include/idmap2/FabricatedOverlay.h +++ b/cmds/idmap2/include/idmap2/FabricatedOverlay.h @@ -14,15 +14,17 @@ * limitations under the License. */ -#ifndef IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H -#define IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H +#ifndef IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ +#define IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ #include #include #include #include +#include #include +#include #include "idmap2/ResourceContainer.h" #include "idmap2/Result.h" @@ -68,7 +70,8 @@ struct FabricatedOverlay { Result InitializeData() const; Result GetCrc() const; - FabricatedOverlay(pb::FabricatedOverlay&& overlay, std::optional crc_from_disk = {}); + explicit FabricatedOverlay(pb::FabricatedOverlay&& overlay, + std::optional crc_from_disk = {}); pb::FabricatedOverlay overlay_pb_; std::optional crc_from_disk_; @@ -102,4 +105,4 @@ struct FabricatedOverlayContainer : public OverlayResourceContainer { } // namespace android::idmap2 -#endif // IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H +#endif // IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ diff --git a/cmds/idmap2/include/idmap2/ResourceContainer.h b/cmds/idmap2/include/idmap2/ResourceContainer.h index 74a6f5666c2a4..c3ba4640bd774 100644 --- a/cmds/idmap2/include/idmap2/ResourceContainer.h +++ b/cmds/idmap2/include/idmap2/ResourceContainer.h @@ -14,9 +14,10 @@ * limitations under the License. */ -#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H -#define IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H +#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ +#define IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ +#include #include #include #include @@ -103,4 +104,4 @@ struct OverlayResourceContainer : public ResourceContainer { } // namespace android::idmap2 -#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H +#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ diff --git a/cmds/idmap2/libidmap2/FabricatedOverlay.cpp b/cmds/idmap2/libidmap2/FabricatedOverlay.cpp index 4f61801aa594d..8352dbb7b619b 100644 --- a/cmds/idmap2/libidmap2/FabricatedOverlay.cpp +++ b/cmds/idmap2/libidmap2/FabricatedOverlay.cpp @@ -23,6 +23,10 @@ #include #include +#include +#include +#include +#include namespace android::idmap2 { @@ -89,7 +93,7 @@ Result FabricatedOverlay::Builder::Build() { auto package = entries.find(package_name); if (package == entries.end()) { package = entries - .insert(std::make_pair<>( + .insert(std::make_pair( package_name, std::map>())) .first; } @@ -98,13 +102,13 @@ Result FabricatedOverlay::Builder::Build() { if (type == package->second.end()) { type = package->second - .insert(std::make_pair<>(type_name.to_string(), std::map())) + .insert(std::make_pair(type_name.to_string(), std::map())) .first; } auto entry = type->second.find(entry_name.to_string()); if (entry == type->second.end()) { - entry = type->second.insert(std::make_pair<>(entry_name.to_string(), TargetValue())).first; + entry = type->second.insert(std::make_pair(entry_name.to_string(), TargetValue())).first; } entry->second = TargetValue{res_entry.data_type, res_entry.data_value}; @@ -299,4 +303,4 @@ Result FabContainer::GetResourceName(ResourceId /* id */) const { return Error("Fabricated overlay does not contain resources."); } -} // namespace android::idmap2 \ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp b/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp index 721612cc567b1..d10a2785aabae 100644 --- a/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp +++ b/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/libidmap2/RawPrintVisitor.cpp b/cmds/idmap2/libidmap2/RawPrintVisitor.cpp index a016a36a2e3df..779538c617f47 100644 --- a/cmds/idmap2/libidmap2/RawPrintVisitor.cpp +++ b/cmds/idmap2/libidmap2/RawPrintVisitor.cpp @@ -18,6 +18,8 @@ #include #include +#include +#include #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/libidmap2/ResourceContainer.cpp b/cmds/idmap2/libidmap2/ResourceContainer.cpp index 9147ccaaa17aa..d11334d21ccd2 100644 --- a/cmds/idmap2/libidmap2/ResourceContainer.cpp +++ b/cmds/idmap2/libidmap2/ResourceContainer.cpp @@ -16,6 +16,11 @@ #include "idmap2/ResourceContainer.h" +#include +#include +#include +#include + #include "androidfw/ApkAssets.h" #include "androidfw/AssetManager.h" #include "androidfw/Util.h" @@ -445,4 +450,4 @@ Result> OverlayResourceContainer::From return std::unique_ptr(result->release()); } -} // namespace android::idmap2 \ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/libidmap2/ResourceUtils.cpp b/cmds/idmap2/libidmap2/ResourceUtils.cpp index e809bf1f4b02e..32c04d2a6caba 100644 --- a/cmds/idmap2/libidmap2/ResourceUtils.cpp +++ b/cmds/idmap2/libidmap2/ResourceUtils.cpp @@ -17,6 +17,7 @@ #include "idmap2/ResourceUtils.h" #include +#include #include "androidfw/StringPiece.h" #include "androidfw/Util.h" diff --git a/cmds/idmap2/tests/FabricatedOverlayTests.cpp b/cmds/idmap2/tests/FabricatedOverlayTests.cpp index 79ab2438af743..468ea0c634c18 100644 --- a/cmds/idmap2/tests/FabricatedOverlayTests.cpp +++ b/cmds/idmap2/tests/FabricatedOverlayTests.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace android::idmap2 { @@ -135,4 +136,4 @@ TEST(FabricatedOverlayTests, SerializeAndDeserialize) { EXPECT_EQ(Res_value::TYPE_INT_DEC, entry->data_type); } -} // namespace android::idmap2 \ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp index 9516ff83d7184..9c6402a6e36e2 100644 --- a/cmds/idmap2/tests/IdmapTests.cpp +++ b/cmds/idmap2/tests/IdmapTests.cpp @@ -83,7 +83,7 @@ TEST(IdmapTests, IdmapFailParsingDifferentVersion) { std::stringstream stream; stream << android::kIdmapMagic; stream << 0xffffffffU; - stream << std::string(kJunkSize, (char)0xffU); + stream << std::string(kJunkSize, static_cast(0xffU)); ASSERT_FALSE(Idmap::FromBinaryStream(stream)); } @@ -92,7 +92,7 @@ TEST(IdmapTests, IdmapFailParsingDifferentMagic) { std::stringstream stream; stream << 0xffffffffU; stream << android::kIdmapCurrentVersion; - stream << std::string(kJunkSize, (char)0xffU); + stream << std::string(kJunkSize, static_cast(0xffU)); ASSERT_FALSE(Idmap::FromBinaryStream(stream)); } diff --git a/cmds/idmap2/tests/R.h b/cmds/idmap2/tests/R.h index ac9b0580d2d94..89219c9c8213e 100644 --- a/cmds/idmap2/tests/R.h +++ b/cmds/idmap2/tests/R.h @@ -66,8 +66,8 @@ namespace R::overlay { constexpr ResourceId str1 = 0x7f02000b; constexpr ResourceId str3 = 0x7f02000c; constexpr ResourceId str4 = 0x7f02000d; - } -} + } // namespace string +} // namespace R::overlay // clang-format on } // namespace android::idmap2