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/bufferinfo/legacy/BufferInfoLibdrm.cpp b/bufferinfo/legacy/BufferInfoLibdrm.cpp
index 52f792f..da89eb5 100644
--- a/bufferinfo/legacy/BufferInfoLibdrm.cpp
+++ b/bufferinfo/legacy/BufferInfoLibdrm.cpp
@@ -37,9 +37,9 @@
struct DroidYuvFormat {
/* Lookup keys */
- int native; /* HAL_PIXEL_FORMAT_ */
+ uint32_t native; /* HAL_PIXEL_FORMAT_ */
enum chroma_order chroma_order; /* chroma order is {Cb, Cr} or {Cr, Cb} */
- int chroma_step; /* Distance in bytes between subsequent chroma pixels. */
+ size_t chroma_step; /* Distance in bytes between subsequent chroma pixels. */
/* Result */
int fourcc; /* DRM_FORMAT_ */
@@ -64,8 +64,8 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-static int get_fourcc_yuv(int native, enum chroma_order chroma_order,
- int chroma_step) {
+static int get_fourcc_yuv(uint32_t native, enum chroma_order chroma_order,
+ size_t chroma_step) {
for (auto droid_yuv_format : kDroidYuvFormats)
if (droid_yuv_format.native == native &&
droid_yuv_format.chroma_order == chroma_order &&
@@ -75,7 +75,7 @@
return -1;
}
-static bool is_yuv(int native) {
+static bool is_yuv(uint32_t native) {
for (auto droid_yuv_format : kDroidYuvFormats)
if (droid_yuv_format.native == native)
return true;