idmap2: fix cpplint warnings
Fix the following to make cpplint happy again:
- Use C++ style casts
- Rename a few header guards
- Add missing includes of standard C++ headers
- Add comments to the end of namespaces
Also, for consistency, always use "..." instead of <...> for local
include files, i.e.
#include "idmap2/.*"
Test: cmds/idmap2/static-checks.sh
Change-Id: Ie735a36d562d1fc51b61f1f0f45aec0d160f602d
diff --git a/cmds/idmap2/idmap2/Create.cpp b/cmds/idmap2/idmap2/Create.cpp
index 9682b6ea..648b78e 100644
--- a/cmds/idmap2/idmap2/Create.cpp
+++ b/cmds/idmap2/idmap2/Create.cpp
@@ -20,6 +20,7 @@
#include <fstream>
#include <memory>
#include <ostream>
+#include <string>
#include <vector>
#include "androidfw/ResourceTypes.h"
diff --git a/cmds/idmap2/idmap2/CreateMultiple.cpp b/cmds/idmap2/idmap2/CreateMultiple.cpp
index abdfaf4..19622c4 100644
--- a/cmds/idmap2/idmap2/CreateMultiple.cpp
+++ b/cmds/idmap2/idmap2/CreateMultiple.cpp
@@ -20,6 +20,7 @@
#include <fstream>
#include <memory>
#include <ostream>
+#include <string>
#include <vector>
#include "Commands.h"
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h
index 55fb5ad..ea931c9 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.h
+++ b/cmds/idmap2/idmap2d/Idmap2Service.h
@@ -17,6 +17,8 @@
#ifndef IDMAP2_IDMAP2D_IDMAP2SERVICE_H_
#define IDMAP2_IDMAP2D_IDMAP2SERVICE_H_
+#include <string>
+
#include <android-base/unique_fd.h>
#include <binder/BinderService.h>
#include <binder/Nullable.h>
diff --git a/cmds/idmap2/libidmap2/PolicyUtils.cpp b/cmds/idmap2/libidmap2/PolicyUtils.cpp
index fc5182a..4e3f54d2 100644
--- a/cmds/idmap2/libidmap2/PolicyUtils.cpp
+++ b/cmds/idmap2/libidmap2/PolicyUtils.cpp
@@ -17,6 +17,8 @@
#include "include/idmap2/PolicyUtils.h"
#include <sstream>
+#include <string>
+#include <vector>
#include "android-base/strings.h"
#include "idmap2/Policies.h"
diff --git a/cmds/idmap2/libidmap2_policies/include/idmap2/Policies.h b/cmds/idmap2/libidmap2_policies/include/idmap2/Policies.h
index 5bd353a..f7987b0 100644
--- a/cmds/idmap2/libidmap2_policies/include/idmap2/Policies.h
+++ b/cmds/idmap2/libidmap2_policies/include/idmap2/Policies.h
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-#ifndef IDMAP2_INCLUDE_IDMAP2_POLICIES_H_
-#define IDMAP2_INCLUDE_IDMAP2_POLICIES_H_
+#ifndef IDMAP2_LIBIDMAP2_POLICIES_INCLUDE_IDMAP2_POLICIES_H_
+#define IDMAP2_LIBIDMAP2_POLICIES_INCLUDE_IDMAP2_POLICIES_H_
#include <array>
#include <string>
+#include <utility>
#include <vector>
#include "android-base/stringprintf.h"
@@ -76,4 +77,4 @@
} // namespace android::idmap2::policy
-#endif // IDMAP2_INCLUDE_IDMAP2_POLICIES_H_
+#endif // IDMAP2_LIBIDMAP2_POLICIES_INCLUDE_IDMAP2_POLICIES_H_
diff --git a/cmds/idmap2/tests/R.h b/cmds/idmap2/tests/R.h
index aed263a..4f2ee1c 100644
--- a/cmds/idmap2/tests/R.h
+++ b/cmds/idmap2/tests/R.h
@@ -14,10 +14,12 @@
* limitations under the License.
*/
-#ifndef IDMAP2_TESTS_R_H
-#define IDMAP2_TESTS_R_H
+#ifndef IDMAP2_TESTS_R_H_
+#define IDMAP2_TESTS_R_H_
-#include <idmap2/ResourceUtils.h>
+#include <string>
+
+#include "idmap2/ResourceUtils.h"
namespace android::idmap2 {
@@ -29,15 +31,15 @@
// clang-format off
namespace R::target {
- namespace integer {
+ namespace integer { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId int1 = 0x7f010000;
- namespace literal {
+ namespace literal { // NOLINT(runtime/indentation_namespace)
inline const std::string int1 = hexify(R::target::integer::int1);
}
}
- namespace string {
+ namespace string { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId not_overlayable = 0x7f020003;
constexpr ResourceId other = 0x7f020004;
constexpr ResourceId policy_actor = 0x7f020005;
@@ -52,19 +54,19 @@
constexpr ResourceId str3 = 0x7f02000f;
constexpr ResourceId str4 = 0x7f020010;
- namespace literal {
+ namespace literal { // NOLINT(runtime/indentation_namespace)
inline const std::string str1 = hexify(R::target::string::str1);
inline const std::string str3 = hexify(R::target::string::str3);
inline const std::string str4 = hexify(R::target::string::str4);
}
- }
-}
+ } // namespace string
+} // namespace R::target
namespace R::overlay {
- namespace integer {
+ namespace integer { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId int1 = 0x7f010000;
}
- namespace string {
+ namespace string { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId str1 = 0x7f020000;
constexpr ResourceId str3 = 0x7f020001;
constexpr ResourceId str4 = 0x7f020002;
@@ -72,10 +74,10 @@
}
namespace R::overlay_shared {
- namespace integer {
+ namespace integer { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId int1 = 0x00010000;
}
- namespace string {
+ namespace string { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId str1 = 0x00020000;
constexpr ResourceId str3 = 0x00020001;
constexpr ResourceId str4 = 0x00020002;
@@ -99,9 +101,9 @@
constexpr ResourceId policy_signature = 0x7f010007;
constexpr ResourceId policy_system = 0x7f010008;
constexpr ResourceId policy_system_vendor = 0x7f010009;
-};
+} // namespace R::system_overlay_invalid::string
// clang-format on
} // namespace android::idmap2
-#endif // IDMAP2_TESTS_R_H
+#endif // IDMAP2_TESTS_R_H_
diff --git a/cmds/idmap2/tests/TestConstants.h b/cmds/idmap2/tests/TestConstants.h
index 6bc924e..74ea18f 100644
--- a/cmds/idmap2/tests/TestConstants.h
+++ b/cmds/idmap2/tests/TestConstants.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef IDMAP2_TESTS_TESTCONSTANTS_H
-#define IDMAP2_TESTS_TESTCONSTANTS_H
+#ifndef IDMAP2_TESTS_TESTCONSTANTS_H_
+#define IDMAP2_TESTS_TESTCONSTANTS_H_
namespace android::idmap2::TestConstants {
@@ -27,4 +27,4 @@
} // namespace android::idmap2::TestConstants
-#endif // IDMAP2_TESTS_TESTCONSTANTS_H
+#endif // IDMAP2_TESTS_TESTCONSTANTS_H_