drm_hwcomposer: CI: Bump-up clang toolchain to v15
Address new clang-tidy findings, in most cases 'misc-const-correctness'
check was addressed by adding 'const' modifier, or in some cases changed
to 'auto' (where it's better for formatting).
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index d968ab3..cecdbe5 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -31,7 +31,7 @@
std::string HwcDisplay::DumpDelta(HwcDisplay::Stats delta) {
if (delta.total_pixops_ == 0)
return "No stats yet";
- double ratio = 1.0 - double(delta.gpu_pixops_) / double(delta.total_pixops_);
+ auto ratio = 1.0 - double(delta.gpu_pixops_) / double(delta.total_pixops_);
std::stringstream ss;
ss << " Total frames count: " << delta.total_frames_ << "\n"
@@ -69,9 +69,9 @@
" VSync remains";
}
- std::string connector_name = IsInHeadlessMode()
- ? "NULL-DISPLAY"
- : GetPipe().connector->Get()->GetName();
+ auto connector_name = IsInHeadlessMode()
+ ? std::string("NULL-DISPLAY")
+ : GetPipe().connector->Get()->GetName();
std::stringstream ss;
ss << "- Display on: " << connector_name << "\n"
@@ -236,7 +236,7 @@
}
uint32_t num_changes = 0;
- for (std::pair<const hwc2_layer_t, HwcLayer> &l : layers_) {
+ for (auto &l : layers_) {
if (l.second.IsTypeChanged()) {
if (layers && num_changes < *num_elements)
layers[num_changes] = l.first;
@@ -257,8 +257,8 @@
return HWC2::Error::None;
}
- std::pair<uint32_t, uint32_t> min = pipeline_->device->GetMinResolution();
- std::pair<uint32_t, uint32_t> max = pipeline_->device->GetMaxResolution();
+ auto min = pipeline_->device->GetMinResolution();
+ auto max = pipeline_->device->GetMaxResolution();
if (width < min.first || height < min.second)
return HWC2::Error::Unsupported;
@@ -296,8 +296,8 @@
auto &hwc_config = configs_.hwc_configs[conf];
static const int32_t kUmPerInch = 25400;
- uint32_t mm_width = configs_.mm_width;
- uint32_t mm_height = configs_.mm_height;
+ auto mm_width = configs_.mm_width;
+ auto mm_height = configs_.mm_height;
auto attribute = static_cast<HWC2::Attribute>(attribute_in);
switch (attribute) {
case HWC2::Attribute::Width:
@@ -364,8 +364,8 @@
} else {
stream << "display-" << GetPipe().connector->Get()->GetId();
}
- std::string string = stream.str();
- size_t length = string.length();
+ auto string = stream.str();
+ auto length = string.length();
if (!name) {
*size = length;
return HWC2::Error::None;
@@ -450,7 +450,7 @@
return HWC2::Error::None;
}
- int PrevModeVsyncPeriodNs = static_cast<int>(
+ auto PrevModeVsyncPeriodNs = static_cast<int>(
1E9 / GetPipe().connector->Get()->GetActiveMode().v_refresh());
auto mode_update_commited_ = false;
@@ -477,7 +477,7 @@
for (std::pair<const hwc2_layer_t, HwcLayer> &l : layers_) {
switch (l.second.GetValidatedType()) {
case HWC2::Composition::Device:
- z_map.emplace(std::make_pair(l.second.GetZOrder(), &l.second));
+ z_map.emplace(l.second.GetZOrder(), &l.second);
break;
case HWC2::Composition::Client:
// Place it at the z_order of the lowest client layer
@@ -489,7 +489,7 @@
}
}
if (use_client_layer)
- z_map.emplace(std::make_pair(client_z_order, &client_layer_));
+ z_map.emplace(client_z_order, &client_layer_);
if (z_map.empty())
return HWC2::Error::BadLayer;
@@ -530,7 +530,7 @@
a_args.composition = current_plan_;
- int ret = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
+ auto ret = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
if (ret) {
if (!a_args.test_only)
@@ -632,10 +632,15 @@
}
auto &bi = client_layer_.GetLayerData().bi;
- hwc_frect_t source_crop = {.left = 0.0F,
- .top = 0.0F,
- .right = static_cast<float>(bi->width),
- .bottom = static_cast<float>(bi->height)};
+ if (!bi) {
+ ALOGE("%s: Invalid state", __func__);
+ return HWC2::Error::BadLayer;
+ }
+
+ auto source_crop = (hwc_frect_t){.left = 0.0F,
+ .top = 0.0F,
+ .right = static_cast<float>(bi->width),
+ .bottom = static_cast<float>(bi->height)};
client_layer_.SetLayerSourceCrop(source_crop);
return HWC2::Error::None;
@@ -709,7 +714,7 @@
: HWC2::Error::BadParameter;
};
- int err = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
+ auto err = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
if (err) {
ALOGE("Failed to apply the dpms composition err=%d", err);
return HWC2::Error::BadParameter;
@@ -940,7 +945,7 @@
/* returns true if composition should be sent to client */
bool HwcDisplay::ProcessClientFlatteningState(bool skip) {
- int flattenning_state = flattenning_state_;
+ const int flattenning_state = flattenning_state_;
if (flattenning_state == ClientFlattenningState::Disabled) {
return false;
}
diff --git a/hwc2_device/HwcDisplayConfigs.cpp b/hwc2_device/HwcDisplayConfigs.cpp
index 6a3ed5a..346572f 100644
--- a/hwc2_device/HwcDisplayConfigs.cpp
+++ b/hwc2_device/HwcDisplayConfigs.cpp
@@ -61,7 +61,7 @@
* mode*/
FillHeadless();
/* Read real configs */
- int ret = connector.UpdateModes();
+ auto ret = connector.UpdateModes();
if (ret != 0) {
ALOGE("Failed to update display modes %d", ret);
return HWC2::Error::BadDisplay;
@@ -79,7 +79,7 @@
preferred_config_id = 0;
uint32_t preferred_config_group_id = 0;
- uint32_t first_config_id = last_config_id;
+ auto first_config_id = last_config_id;
uint32_t last_group_id = 1;
/* Group modes */
@@ -143,7 +143,7 @@
}
}
- bool has_both = has_interlaced && has_progressive;
+ auto has_both = has_interlaced && has_progressive;
if (!has_both) {
continue;
}
@@ -159,7 +159,7 @@
continue;
}
- bool disable = group_contains_preferred_interlaced
+ auto disable = group_contains_preferred_interlaced
? !hwc_config.second.IsInterlaced()
: hwc_config.second.IsInterlaced();
diff --git a/hwc2_device/HwcLayer.cpp b/hwc2_device/HwcLayer.cpp
index c278732..589a0a7 100644
--- a/hwc2_device/HwcLayer.cpp
+++ b/hwc2_device/HwcLayer.cpp
@@ -205,6 +205,11 @@
void HwcLayer::PopulateLayerData(bool test) {
ImportFb();
+ if (!layer_data_.bi) {
+ ALOGE("%s: Invalid state", __func__);
+ return;
+ }
+
if (blend_mode_ != BufferBlendMode::kUndefined) {
layer_data_.bi->blend_mode = blend_mode_;
}
@@ -227,7 +232,7 @@
return false;
}
- int seq = swchain_lookup_table_[unique_id];
+ auto seq = swchain_lookup_table_[unique_id];
if (swchain_cache_.count(seq) == 0) {
return false;
@@ -274,7 +279,7 @@
return;
}
- int seq = swchain_lookup_table_[unique_id];
+ auto seq = swchain_lookup_table_[unique_id];
if (swchain_cache_.count(seq) == 0) {
swchain_cache_[seq] = {};
diff --git a/hwc2_device/hwc2_device.cpp b/hwc2_device/hwc2_device.cpp
index a6dedb4..2242391 100644
--- a/hwc2_device/hwc2_device.cpp
+++ b/hwc2_device/hwc2_device.cpp
@@ -35,11 +35,11 @@
* to the short "android::HwcLayer::SetLayerBuffer" for better logs readability
*/
static std::string GetFuncName(const char *pretty_function) {
- std::string str(pretty_function);
+ const std::string str(pretty_function);
const char *start = "func = &";
- size_t p1 = str.find(start);
+ auto p1 = str.find(start);
p1 += strlen(start);
- size_t p2 = str.find(',', p1);
+ auto p2 = str.find(',', p1);
return str.substr(p1, p2 - p1);
}
@@ -102,7 +102,7 @@
static int HookDevClose(hw_device_t *dev) {
// NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast): Safe
auto *hwc2_dev = reinterpret_cast<hwc2_device_t *>(dev);
- std::unique_ptr<DrmHwcTwo> ctx(ToDrmHwcTwo(hwc2_dev));
+ const std::unique_ptr<DrmHwcTwo> ctx(ToDrmHwcTwo(hwc2_dev));
return 0;
}