drm_hwcomposer: enable code analysis using clang-tidy
Drm hwcomposer project has some code-style inconsistencies.
This is the initial step to unify code-style of the code.
Clang-tidy is a great tool which can not only suggest correct styling,
but also allow predicting the errors in the code and suggest correct
coding approaches to avoid potential weaknesses.
CI was tuned to check clang-tidy recommendation for some part of the
code which is ready ATM (can be built outside AOSP tree).
For this part a limited set of clang-tidy checks has applied (coarse check).
Header files aren't checked at all.
Starting from now new code files must be included into the list that is
checked by almost all clang-tidy checks (fine checklist). New header files
should be also included into this list.
See '.gitlab-ci-clang-tidy-fine.sh'.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/DrmConnector.cpp b/drm/DrmConnector.cpp
index 11c2bd2..cfafc1d 100644
--- a/drm/DrmConnector.cpp
+++ b/drm/DrmConnector.cpp
@@ -18,11 +18,11 @@
#include "DrmConnector.h"
-#include <errno.h>
-#include <stdint.h>
#include <xf86drmMode.h>
#include <array>
+#include <cerrno>
+#include <cstdint>
#include <sstream>
#include "DrmDevice.h"
@@ -30,7 +30,7 @@
namespace android {
-constexpr size_t TYPES_COUNT = 17;
+constexpr size_t kTypesCount = 17;
DrmConnector::DrmConnector(DrmDevice *drm, drmModeConnectorPtr c,
DrmEncoder *current_encoder,
@@ -144,19 +144,19 @@
}
std::string DrmConnector::name() const {
- constexpr std::array<const char *, TYPES_COUNT> names =
+ constexpr std::array<const char *, kTypesCount> kNames =
{"None", "VGA", "DVI-I", "DVI-D", "DVI-A", "Composite",
"SVIDEO", "LVDS", "Component", "DIN", "DP", "HDMI-A",
"HDMI-B", "TV", "eDP", "Virtual", "DSI"};
- if (type_ < TYPES_COUNT) {
+ if (type_ < kTypesCount) {
std::ostringstream name_buf;
- name_buf << names[type_] << "-" << type_id_;
+ name_buf << kNames[type_] << "-" << type_id_;
return name_buf.str();
- } else {
- ALOGE("Unknown type in connector %d, could not make his name", id_);
- return "None";
}
+
+ ALOGE("Unknown type in connector %d, could not make his name", id_);
+ return "None";
}
int DrmConnector::UpdateModes() {
@@ -194,7 +194,7 @@
}
}
modes_.swap(new_modes);
- if (!preferred_mode_found && modes_.size() != 0) {
+ if (!preferred_mode_found && !modes_.empty()) {
preferred_mode_id_ = modes_[0].id();
}
return 0;