diff options
author | Roman Stratiienko <r.stratiienko@gmail.com> | 2021-02-15 13:44:19 +0200 |
---|---|---|
committer | Roman Stratiienko <r.stratiienko@gmail.com> | 2021-03-03 16:12:22 +0200 |
commit | b3b5c1e937d6bbbd44b65f5c36305bdc8fbb3246 (patch) | |
tree | 5049e1aa7f8ab0918d3c84e6150ad3555618d4eb /drm | |
parent | 6a10c4ce1f5601051c44b0f0cd85b1059e0a1bba (diff) | |
download | drm_hwcomposer-b3b5c1e937d6bbbd44b65f5c36305bdc8fbb3246.tar.gz |
drm_hwcomposer: clang-tidy: enable cppcoreguidelines-* checks
Our code isn't ready for the following checks therefore keep disabled
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-pro-bounds-constant-array-index
-cppcoreguidelines-pro-bounds-pointer-arithmetic
-cppcoreguidelines-pro-type-cstyle-cast
-cppcoreguidelines-pro-type-vararg
-cppcoreguidelines-avoid-magic-numbers
-cppcoreguidelines-macro-usage
-cppcoreguidelines-avoid-c-arrays
+ fixed existing tidy warnings for these checks.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Diffstat (limited to 'drm')
-rw-r--r-- | drm/DrmConnector.cpp | 2 | ||||
-rw-r--r-- | drm/DrmConnector.h | 2 | ||||
-rw-r--r-- | drm/DrmDevice.cpp | 10 | ||||
-rw-r--r-- | drm/DrmEventListener.cpp | 11 | ||||
-rw-r--r-- | drm/DrmEventListener.h | 2 | ||||
-rw-r--r-- | drm/DrmGenericImporter.cpp | 5 | ||||
-rw-r--r-- | drm/DrmPlane.cpp | 2 | ||||
-rw-r--r-- | drm/DrmPlane.h | 2 | ||||
-rw-r--r-- | drm/ResourceManager.cpp | 6 | ||||
-rw-r--r-- | drm/ResourceManager.h | 2 | ||||
-rw-r--r-- | drm/VSyncWorker.cpp | 8 |
11 files changed, 23 insertions, 29 deletions
diff --git a/drm/DrmConnector.cpp b/drm/DrmConnector.cpp index 7155bf2..0468527 100644 --- a/drm/DrmConnector.cpp +++ b/drm/DrmConnector.cpp @@ -91,7 +91,7 @@ int DrmConnector::UpdateEdidProperty() { } int DrmConnector::GetEdidBlob(drmModePropertyBlobPtr &blob) { - uint64_t blob_id; + uint64_t blob_id = 0; int ret = UpdateEdidProperty(); if (ret) { return ret; diff --git a/drm/DrmConnector.h b/drm/DrmConnector.h index 8533af8..3bc18c8 100644 --- a/drm/DrmConnector.h +++ b/drm/DrmConnector.h @@ -111,7 +111,7 @@ class DrmConnector { std::vector<DrmEncoder *> possible_encoders_; - uint32_t preferred_mode_id_; + uint32_t preferred_mode_id_{}; }; } // namespace android diff --git a/drm/DrmDevice.cpp b/drm/DrmDevice.cpp index 52d81d5..150aa01 100644 --- a/drm/DrmDevice.cpp +++ b/drm/DrmDevice.cpp @@ -54,7 +54,7 @@ static void trim(std::string *str) { namespace android { static std::vector<std::string> read_primary_display_order_prop() { - std::array<char, PROPERTY_VALUE_MAX> display_order_buf; + std::array<char, PROPERTY_VALUE_MAX> display_order_buf{}; property_get("vendor.hwc.drm.primary_display_order", display_order_buf.data(), "..."); @@ -503,8 +503,7 @@ int DrmDevice::AttachWriteback(DrmConnector *display_conn) { int DrmDevice::CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id) const { - struct drm_mode_create_blob create_blob; - memset(&create_blob, 0, sizeof(create_blob)); + struct drm_mode_create_blob create_blob {}; create_blob.length = length; create_blob.data = (__u64)data; @@ -521,8 +520,7 @@ int DrmDevice::DestroyPropertyBlob(uint32_t blob_id) const { if (!blob_id) return 0; - struct drm_mode_destroy_blob destroy_blob; - memset(&destroy_blob, 0, sizeof(destroy_blob)); + struct drm_mode_destroy_blob destroy_blob {}; destroy_blob.blob_id = (__u32)blob_id; int ret = drmIoctl(fd(), DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy_blob); if (ret) { @@ -538,7 +536,7 @@ DrmEventListener *DrmDevice::event_listener() { int DrmDevice::GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name, DrmProperty *property) const { - drmModeObjectPropertiesPtr props; + drmModeObjectPropertiesPtr props = nullptr; props = drmModeObjectGetProperties(fd(), obj_id, obj_type); if (!props) { diff --git a/drm/DrmEventListener.cpp b/drm/DrmEventListener.cpp index 13a1273..a6eee47 100644 --- a/drm/DrmEventListener.cpp +++ b/drm/DrmEventListener.cpp @@ -46,8 +46,7 @@ int DrmEventListener::Init() { return uevent_fd_.get(); } - struct sockaddr_nl addr; - memset(&addr, 0, sizeof(addr)); + struct sockaddr_nl addr {}; addr.nl_family = AF_NETLINK; addr.nl_pid = 0; addr.nl_groups = 0xFFFFFFFF; @@ -80,14 +79,14 @@ void DrmEventListener::FlipHandler(int /* fd */, unsigned int /* sequence */, return; handler->HandleEvent((uint64_t)tv_sec * 1000 * 1000 + tv_usec); - delete handler; + delete handler; // NOLINT(cppcoreguidelines-owning-memory) } void DrmEventListener::UEventHandler() { char buffer[1024]; - int ret; + int ret = 0; - struct timespec ts; + struct timespec ts {}; uint64_t timestamp = 0; ret = clock_gettime(CLOCK_MONOTONIC, &ts); @@ -127,7 +126,7 @@ void DrmEventListener::UEventHandler() { } void DrmEventListener::Routine() { - int ret; + int ret = 0; do { ret = select(max_fd_ + 1, &fds_, nullptr, nullptr, nullptr); } while (ret == -1 && errno == EINTR); diff --git a/drm/DrmEventListener.h b/drm/DrmEventListener.h index 9f9a4ba..c880a8c 100644 --- a/drm/DrmEventListener.h +++ b/drm/DrmEventListener.h @@ -53,7 +53,7 @@ class DrmEventListener : public Worker { private: void UEventHandler(); - fd_set fds_; + fd_set fds_{}; UniqueFd uevent_fd_; int max_fd_ = -1; diff --git a/drm/DrmGenericImporter.cpp b/drm/DrmGenericImporter.cpp index 6627cc8..893eb8d 100644 --- a/drm/DrmGenericImporter.cpp +++ b/drm/DrmGenericImporter.cpp @@ -123,10 +123,7 @@ int DrmGenericImporter::ReleaseHandle(uint32_t gem_handle) { } int DrmGenericImporter::CloseHandle(uint32_t gem_handle) { - struct drm_gem_close gem_close; - - memset(&gem_close, 0, sizeof(gem_close)); - + struct drm_gem_close gem_close {}; gem_close.handle = gem_handle; int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close); if (ret) diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp index a7ad3c0..570905f 100644 --- a/drm/DrmPlane.cpp +++ b/drm/DrmPlane.cpp @@ -47,7 +47,7 @@ int DrmPlane::Init() { return ret; } - uint64_t type; + uint64_t type = 0; std::tie(ret, type) = p.value(); if (ret) { ALOGE("Failed to get plane type property value"); diff --git a/drm/DrmPlane.h b/drm/DrmPlane.h index 7a915cc..2e2c121 100644 --- a/drm/DrmPlane.h +++ b/drm/DrmPlane.h @@ -70,7 +70,7 @@ class DrmPlane { uint32_t possible_crtc_mask_; - uint32_t type_; + uint32_t type_{}; std::vector<uint32_t> formats_; diff --git a/drm/ResourceManager.cpp b/drm/ResourceManager.cpp index 3e16fbb..50c33aa 100644 --- a/drm/ResourceManager.cpp +++ b/drm/ResourceManager.cpp @@ -46,7 +46,7 @@ int ResourceManager::Init() { std::ostringstream path; path << path_pattern << idx; - struct stat buf; + struct stat buf {}; if (stat(path.str().c_str(), &buf)) break; @@ -75,8 +75,8 @@ int ResourceManager::Init() { int ResourceManager::AddDrmDevice(std::string const &path) { std::unique_ptr<DrmDevice> drm = std::make_unique<DrmDevice>(); - int displays_added; - int ret; + int displays_added = 0; + int ret = 0; std::tie(ret, displays_added) = drm->Init(path.c_str(), num_displays_); if (ret) return ret; diff --git a/drm/ResourceManager.h b/drm/ResourceManager.h index a17ae03..fca6e1f 100644 --- a/drm/ResourceManager.h +++ b/drm/ResourceManager.h @@ -53,7 +53,7 @@ class ResourceManager { std::vector<std::shared_ptr<Importer>> importers_; const gralloc_module_t *gralloc_; - bool scale_with_gpu_; + bool scale_with_gpu_{}; }; } // namespace android diff --git a/drm/VSyncWorker.cpp b/drm/VSyncWorker.cpp index 9756a6a..e9f4f9c 100644 --- a/drm/VSyncWorker.cpp +++ b/drm/VSyncWorker.cpp @@ -53,7 +53,7 @@ void VSyncWorker::RegisterClientCallback(hwc2_callback_data_t data, hwc2_function_pointer_t hook) { Lock(); vsync_callback_data_ = data; - vsync_callback_hook_ = reinterpret_cast<HWC2_PFN_VSYNC>(hook); + vsync_callback_hook_ = (HWC2_PFN_VSYNC)hook; Unlock(); } @@ -90,7 +90,7 @@ int64_t VSyncWorker::GetPhasedVSync(int64_t frame_ns, int64_t current) const { static const int64_t kOneSecondNs = 1 * 1000 * 1000 * 1000; int VSyncWorker::SyntheticWaitVBlank(int64_t *timestamp) { - struct timespec vsync; + struct timespec vsync {}; int ret = clock_gettime(CLOCK_MONOTONIC, &vsync); if (ret) return ret; @@ -119,7 +119,7 @@ int VSyncWorker::SyntheticWaitVBlank(int64_t *timestamp) { } void VSyncWorker::Routine() { - int ret; + int ret = 0; Lock(); if (!enabled_) { @@ -147,7 +147,7 @@ void VSyncWorker::Routine() { DRM_VBLANK_RELATIVE | (high_crtc & DRM_VBLANK_HIGH_CRTC_MASK)); vblank.request.sequence = 1; - int64_t timestamp; + int64_t timestamp = 0; ret = drmWaitVBlank(drm_->fd(), &vblank); if (ret == -EINTR) return; |