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/bufferinfo/BufferInfoGetter.h b/bufferinfo/BufferInfoGetter.h
index 19ff02b..60ca985 100644
--- a/bufferinfo/BufferInfoGetter.h
+++ b/bufferinfo/BufferInfoGetter.h
@@ -51,7 +51,7 @@
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override = 0;
- static LegacyBufferInfoGetter *CreateInstance();
+ static std::unique_ptr<LegacyBufferInfoGetter> CreateInstance();
static uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
const gralloc_module_t *gralloc_;
@@ -60,19 +60,18 @@
#ifdef DISABLE_LEGACY_GETTERS
#define LEGACY_BUFFER_INFO_GETTER(getter_)
#else
-#define LEGACY_BUFFER_INFO_GETTER(getter_) \
- LegacyBufferInfoGetter *LegacyBufferInfoGetter::CreateInstance() { \
- auto *instance = new getter_(); \
- if (!instance) \
- return NULL; \
- \
- int ret = instance->Init(); \
- if (ret) { \
- ALOGE("Failed to initialize the " #getter_ " getter %d", ret); \
- delete instance; \
- return NULL; \
- } \
- return instance; \
+#define LEGACY_BUFFER_INFO_GETTER(getter_) \
+ std::unique_ptr<LegacyBufferInfoGetter> \
+ LegacyBufferInfoGetter::CreateInstance() { \
+ auto instance = std::make_unique<getter_>(); \
+ if (instance) { \
+ int ret = instance->Init(); \
+ if (ret) { \
+ ALOGE("Failed to initialize the " #getter_ " getter %d", ret); \
+ instance.reset(); \
+ } \
+ } \
+ return std::move(instance); \
}
#endif