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 | |
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>
27 files changed, 70 insertions, 62 deletions
diff --git a/.ci/.gitlab-ci-clang-tidy-coarse.sh b/.ci/.gitlab-ci-clang-tidy-coarse.sh index a2d367c..4ecf19e 100755 --- a/.ci/.gitlab-ci-clang-tidy-coarse.sh +++ b/.ci/.gitlab-ci-clang-tidy-coarse.sh @@ -3,6 +3,16 @@ . ./.ci/.common.sh TIDY_COARSE_CHECKS="-*,android-*,bugprone-*,cert-*,clang-analyzer-*," +TIDY_COARSE_CHECKS+="cppcoreguidelines-*," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-pro-bounds-array-to-pointer-decay," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-pro-bounds-constant-array-index," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-pro-bounds-pointer-arithmetic," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-pro-type-cstyle-cast," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-pro-type-union-access," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-pro-type-vararg," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-avoid-magic-numbers," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-macro-usage," +TIDY_COARSE_CHECKS+="-cppcoreguidelines-avoid-c-arrays," TIDY_COARSE_CHECKS+="google-*," TIDY_COARSE_CHECKS+="-google-readability-braces-around-statements," TIDY_COARSE_CHECKS+="-google-readability-casting," diff --git a/DrmHwcTwo.cpp b/DrmHwcTwo.cpp index dc2cd88..694a7c5 100644 --- a/DrmHwcTwo.cpp +++ b/DrmHwcTwo.cpp @@ -33,7 +33,7 @@ namespace android { -DrmHwcTwo::DrmHwcTwo() { +DrmHwcTwo::DrmHwcTwo() : hwc2_device() { common.tag = HARDWARE_DEVICE_TAG; common.version = HWC_DEVICE_API_VERSION_2_0; common.close = HookDevClose; @@ -85,6 +85,7 @@ HWC2::Error DrmHwcTwo::Init() { auto &drm_devices = resource_manager_.getDrmDevices(); for (auto &device : drm_devices) { + // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) device->RegisterHotplugHandler(new DrmHotplugHandler(this, device.get())); } return ret; @@ -287,7 +288,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::Init(std::vector<DrmPlane *> *planes) { HWC2::Error DrmHwcTwo::HwcDisplay::ChosePreferredConfig() { // Fetch the number of modes from the display - uint32_t num_configs; + uint32_t num_configs = 0; HWC2::Error err = GetDisplayConfigs(&num_configs, nullptr); if (err != HWC2::Error::None || !num_configs) return err; @@ -969,7 +970,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayIdentificationData( uint8_t *outPort, uint32_t *outDataSize, uint8_t *outData) { supported(__func__); - drmModePropertyBlobPtr blob; + drmModePropertyBlobPtr blob = nullptr; if (connector_->GetEdidBlob(blob)) { ALOGE("Failed to get edid property value."); @@ -1514,17 +1515,19 @@ int DrmHwcTwo::HookDevOpen(const struct hw_module_t *module, const char *name, return -EINVAL; } - ctx->common.module = const_cast<hw_module_t *>(module); + ctx->common.module = (hw_module_t *)module; *dev = &ctx->common; ctx.release(); // NOLINT(bugprone-unused-return-value) return 0; } } // namespace android +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) static struct hw_module_methods_t hwc2_module_methods = { .open = android::DrmHwcTwo::HookDevOpen, }; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .module_api_version = HARDWARE_MODULE_API_VERSION(2, 0), diff --git a/DrmHwcTwo.h b/DrmHwcTwo.h index c75b2e9..6c5431e 100644 --- a/DrmHwcTwo.h +++ b/DrmHwcTwo.h @@ -350,8 +350,8 @@ class DrmHwcTwo : public hwc2_device_t { std::map<hwc2_layer_t, HwcLayer> layers_; HwcLayer client_layer_; UniqueFd present_fence_; - int32_t color_mode_; - std::array<float, MATRIX_SIZE> color_transform_matrix_; + int32_t color_mode_{}; + std::array<float, MATRIX_SIZE> color_transform_matrix_{}; android_color_transform_t color_transform_hint_; uint32_t frame_no_ = 0; diff --git a/backend/Backend.cpp b/backend/Backend.cpp index 15a9ff1..16e2859 100644 --- a/backend/Backend.cpp +++ b/backend/Backend.cpp @@ -63,7 +63,7 @@ HWC2::Error Backend::ValidateDisplay(DrmHwcTwo::HwcDisplay *display, size_t extra_client = (z_map.size() - client_size) - avail_planes; if (extra_client > 0) { int start = 0; - size_t steps; + size_t steps = 0; if (client_size != 0) { size_t prepend = std::min((size_t)client_start, extra_client); size_t append = std::min(z_map.size() - (client_start + client_size), @@ -136,6 +136,7 @@ bool Backend::IsClientLayer(DrmHwcTwo::HwcDisplay *display, display->resource_manager()->ForcedScalingWithGpu()); } +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) REGISTER_BACKEND("generic", Backend); } // namespace android diff --git a/backend/BackendClient.cpp b/backend/BackendClient.cpp index 033a35c..bef536a 100644 --- a/backend/BackendClient.cpp +++ b/backend/BackendClient.cpp @@ -30,6 +30,7 @@ HWC2::Error BackendClient::ValidateDisplay(DrmHwcTwo::HwcDisplay *display, return HWC2::Error::HasChanges; } +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) REGISTER_BACKEND("client", BackendClient); } // namespace android diff --git a/backend/BackendRCarDu.cpp b/backend/BackendRCarDu.cpp index e85fa71..6585406 100644 --- a/backend/BackendRCarDu.cpp +++ b/backend/BackendRCarDu.cpp @@ -40,6 +40,7 @@ bool BackendRCarDu::IsClientLayer(DrmHwcTwo::HwcDisplay *display, return Backend::IsClientLayer(display, layer); } +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) REGISTER_BACKEND("rcar-du", BackendRCarDu); } // namespace android
\ No newline at end of file diff --git a/bufferinfo/BufferInfoGetter.cpp b/bufferinfo/BufferInfoGetter.cpp index d8e63a9..477228b 100644 --- a/bufferinfo/BufferInfoGetter.cpp +++ b/bufferinfo/BufferInfoGetter.cpp @@ -53,12 +53,12 @@ bool BufferInfoGetter::IsHandleUsable(buffer_handle_t handle) { hwc_drm_bo_t bo; memset(&bo, 0, sizeof(hwc_drm_bo_t)); - if (ConvertBoInfo(handle, &bo) != 0) + if (ConvertBoInfo(handle, &bo) != 0) { return false; - - if (bo.prime_fds[0] == 0) + } + if (bo.prime_fds[0] == 0) { return false; - + } return true; } diff --git a/bufferinfo/legacy/BufferInfoLibdrm.cpp b/bufferinfo/legacy/BufferInfoLibdrm.cpp index 1634f8a..1953e36 100644 --- a/bufferinfo/legacy/BufferInfoLibdrm.cpp +++ b/bufferinfo/legacy/BufferInfoLibdrm.cpp @@ -84,9 +84,9 @@ static bool is_yuv(int native) { bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle, hwc_drm_bo_t *bo) { - struct android_ycbcr ycbcr; - enum chroma_order chroma_order; - int ret; + struct android_ycbcr ycbcr {}; + enum chroma_order chroma_order {}; + int ret = 0; if (!gralloc_->lock_ycbcr) { static std::once_flag once; diff --git a/bufferinfo/legacy/BufferInfoMaliHisi.cpp b/bufferinfo/legacy/BufferInfoMaliHisi.cpp index 559cb5c..ddb12ab 100644 --- a/bufferinfo/legacy/BufferInfoMaliHisi.cpp +++ b/bufferinfo/legacy/BufferInfoMaliHisi.cpp @@ -68,9 +68,9 @@ uint64_t BufferInfoMaliHisi::ConvertGrallocFormatToDrmModifiers( int BufferInfoMaliHisi::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { - bool is_rgb; + bool is_rgb = false; - auto const *hnd = reinterpret_cast<private_handle_t const *>(handle); + auto *hnd = (private_handle_t const *)handle; if (!hnd) return -EINVAL; diff --git a/bufferinfo/legacy/BufferInfoMaliMediatek.cpp b/bufferinfo/legacy/BufferInfoMaliMediatek.cpp index 13c7a34..f6e0ac5 100644 --- a/bufferinfo/legacy/BufferInfoMaliMediatek.cpp +++ b/bufferinfo/legacy/BufferInfoMaliMediatek.cpp @@ -34,7 +34,7 @@ LEGACY_BUFFER_INFO_GETTER(BufferInfoMaliMediatek); int BufferInfoMaliMediatek::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { - auto const *hnd = reinterpret_cast<private_handle_t const *>(handle); + auto *hnd = (private_handle_t const *)handle; if (!hnd) return -EINVAL; diff --git a/bufferinfo/legacy/BufferInfoMaliMeson.cpp b/bufferinfo/legacy/BufferInfoMaliMeson.cpp index 1dfe4d2..ad10203 100644 --- a/bufferinfo/legacy/BufferInfoMaliMeson.cpp +++ b/bufferinfo/legacy/BufferInfoMaliMeson.cpp @@ -63,7 +63,7 @@ uint64_t BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers( int BufferInfoMaliMeson::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { - auto const *hnd = reinterpret_cast<private_handle_t const *>(handle); + auto *hnd = (private_handle_t const *)handle; if (!hnd) return -EINVAL; diff --git a/compositor/DrmDisplayComposition.cpp b/compositor/DrmDisplayComposition.cpp index a8dc0fc..ef151a1 100644 --- a/compositor/DrmDisplayComposition.cpp +++ b/compositor/DrmDisplayComposition.cpp @@ -103,7 +103,7 @@ int DrmDisplayComposition::Plan(std::vector<DrmPlane *> *primary_planes, for (size_t i = 0; i < layers_.size(); ++i) to_composite.emplace(std::make_pair(i, &layers_[i])); - int ret; + int ret = 0; std::tie(ret, composition_planes_) = planner_->ProvisionPlanes(to_composite, crtc_, primary_planes, @@ -122,7 +122,7 @@ int DrmDisplayComposition::Plan(std::vector<DrmPlane *> *primary_planes, // make sure that source layers are ordered based on zorder std::sort(i.source_layers().begin(), i.source_layers().end()); - std::vector<DrmPlane *> *container; + std::vector<DrmPlane *> *container = nullptr; if (i.plane()->type() == DRM_PLANE_TYPE_PRIMARY) container = primary_planes; else diff --git a/compositor/DrmDisplayCompositor.cpp b/compositor/DrmDisplayCompositor.cpp index 5331b6d..8d96d0e 100644 --- a/compositor/DrmDisplayCompositor.cpp +++ b/compositor/DrmDisplayCompositor.cpp @@ -76,7 +76,7 @@ DrmDisplayCompositor::DrmDisplayCompositor() writeback_fence_(-1), flattening_state_(FlatteningState::kNone), frames_flattened_(0) { - struct timespec ts; + struct timespec ts {}; if (clock_gettime(CLOCK_MONOTONIC, &ts)) return; dump_last_timestamp_ns_ = ts.tv_sec * 1000 * 1000 * 1000 + ts.tv_nsec; @@ -189,7 +189,7 @@ int DrmDisplayCompositor::DisablePlanes(DrmDisplayComposition *display_comp) { return -ENOMEM; } - int ret; + int ret = 0; std::vector<DrmCompositionPlane> &comp_planes = display_comp ->composition_planes(); for (DrmCompositionPlane &comp_plane : comp_planes) { @@ -638,8 +638,7 @@ int DrmDisplayCompositor::ApplyDpms(DrmDisplayComposition *display_comp) { std::tuple<int, uint32_t> DrmDisplayCompositor::CreateModeBlob( const DrmMode &mode) { - struct drm_mode_modeinfo drm_mode; - memset(&drm_mode, 0, sizeof(drm_mode)); + struct drm_mode_modeinfo drm_mode {}; mode.ToDrmModeModeInfo(&drm_mode); uint32_t id = 0; @@ -1138,7 +1137,7 @@ void DrmDisplayCompositor::Dump(std::ostringstream *out) const { uint64_t num_frames = dump_frames_composited_; dump_frames_composited_ = 0; - struct timespec ts; + struct timespec ts {}; ret = clock_gettime(CLOCK_MONOTONIC, &ts); if (ret) { pthread_mutex_unlock(&lock_); diff --git a/compositor/DrmDisplayCompositor.h b/compositor/DrmDisplayCompositor.h index ab3f867..92dadca 100644 --- a/compositor/DrmDisplayCompositor.h +++ b/compositor/DrmDisplayCompositor.h @@ -143,11 +143,11 @@ class DrmDisplayCompositor { ModeState mode_; - int framebuffer_index_; + int framebuffer_index_{}; DrmFramebuffer framebuffers_[DRM_DISPLAY_BUFFERS]; // mutable since we need to acquire in Dump() - mutable pthread_mutex_t lock_; + mutable pthread_mutex_t lock_{}; // State tracking progress since our last Dump(). These are mutable since // we need to reset them on every Dump() call. diff --git a/compositor/Planner.cpp b/compositor/Planner.cpp index fb6a8c3..b6f10d2 100644 --- a/compositor/Planner.cpp +++ b/compositor/Planner.cpp @@ -45,7 +45,7 @@ std::vector<DrmPlane *> Planner::GetUsablePlanes( int Planner::PlanStage::ValidatePlane(DrmPlane *plane, DrmHwcLayer *layer) { int ret = 0; - uint64_t blend; + uint64_t blend = UINT64_MAX; if ((plane->rotation_property().id() == 0) && layer->transform != DrmHwcTransform::kIdentity) { @@ -122,7 +122,7 @@ int PlanStageProtected::ProvisionPlanes( std::vector<DrmCompositionPlane> *composition, std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc, std::vector<DrmPlane *> *planes) { - int ret; + int ret = 0; for (auto i = layers.begin(); i != layers.end();) { if (!i->second->protected_usage()) { ++i; 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; diff --git a/utils/hwcutils.cpp b/utils/hwcutils.cpp index 9a49c41..35c9fb6 100644 --- a/utils/hwcutils.cpp +++ b/utils/hwcutils.cpp @@ -72,13 +72,12 @@ int DrmHwcBuffer::ImportBuffer(buffer_handle_t handle, Importer *importer) { } int DrmHwcNativeHandle::CopyBufferHandle(buffer_handle_t handle) { - native_handle_t *handle_copy; + native_handle_t *handle_copy = nullptr; GraphicBufferMapper &gm(GraphicBufferMapper::get()); - int ret; + int ret = 0; ret = gm.getGrallocMapper().importBuffer(handle, - const_cast<buffer_handle_t *>( - &handle_copy)); + (buffer_handle_t *)&handle_copy); if (ret) { ALOGE("Failed to import buffer handle %d", ret); |