drm_hwcomposer: CI: Upgrade clang-* to v12
- Enabling readability-ientifier-naming tidy check does require to specify
MacroDefinitionIgnoredRegexp key, which is available only in clang-tidy-12.
- Clang-12 isn't available on ubuntu 20.10, therefore upgrade to 21.04.
- "DEBIAN_FRONTEND: noninteractive" is required to prevent ubuntu 21.04
from hanging, presumably due to waiting for the user input.
- A positive side effect of upgrading to clang-12 is new clang-tidy-12,
which exposed new issues in the code which is also fixed by this commit,
e.g:
Failed cppcoreguidelines-narrowing-conversions check with error:
error: narrowing conversion from 'uint32_t' (aka 'unsigned int') to 'float'
require explicit casting to pass the check, while some of such fails are caused
by incorrect variable type and fixed by changing the type to correct one.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/DrmHwcTwo.cpp b/DrmHwcTwo.cpp
index 02667cf..d9ba4f3 100644
--- a/DrmHwcTwo.cpp
+++ b/DrmHwcTwo.cpp
@@ -48,7 +48,7 @@
HWC2::Error DrmHwcTwo::CreateDisplay(hwc2_display_t displ,
HWC2::DisplayType type) {
- DrmDevice *drm = resource_manager_.GetDrmDevice(displ);
+ DrmDevice *drm = resource_manager_.GetDrmDevice(static_cast<int>(displ));
if (!drm) {
ALOGE("Failed to get a valid drmresource");
return HWC2::Error::NoResources;
@@ -413,22 +413,26 @@
auto attribute = static_cast<HWC2::Attribute>(attribute_in);
switch (attribute) {
case HWC2::Attribute::Width:
- *value = mode->h_display();
+ *value = static_cast<int>(mode->h_display());
break;
case HWC2::Attribute::Height:
- *value = mode->v_display();
+ *value = static_cast<int>(mode->v_display());
break;
case HWC2::Attribute::VsyncPeriod:
// in nanoseconds
- *value = 1000.0 * 1000.0 * 1000.0 / mode->v_refresh();
+ *value = static_cast<int>(1E9 / mode->v_refresh());
break;
case HWC2::Attribute::DpiX:
// Dots per 1000 inches
- *value = mm_width ? (mode->h_display() * kUmPerInch) / mm_width : -1;
+ *value = mm_width
+ ? static_cast<int>(mode->h_display() * kUmPerInch / mm_width)
+ : -1;
break;
case HWC2::Attribute::DpiY:
// Dots per 1000 inches
- *value = mm_height ? (mode->v_display() * kUmPerInch) / mm_height : -1;
+ *value = mm_height ? static_cast<int>(mode->v_display() * kUmPerInch /
+ mm_height)
+ : -1;
break;
#if PLATFORM_SDK_VERSION > 29
case HWC2::Attribute::ConfigGroup:
@@ -786,8 +790,8 @@
hwc_frect_t source_crop = {.left = 0.0F,
.top = 0.0F,
- .right = bo.width + 0.0F,
- .bottom = bo.height + 0.0F};
+ .right = static_cast<float>(bo.width),
+ .bottom = static_cast<float>(bo.height)};
client_layer_.SetLayerSourceCrop(source_crop);
return HWC2::Error::None;
@@ -909,7 +913,7 @@
if (mode.id() == 0)
return HWC2::Error::BadConfig;
- *outVsyncPeriod = 1E9 / mode.v_refresh();
+ *outVsyncPeriod = static_cast<hwc2_vsync_period_t>(1E9 / mode.v_refresh());
return HWC2::Error::None;
}