aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Stratiienko <roman.stratiienko@globallogic.com>2019-11-06 15:03:12 +0200
committerRoman Stratiienko <roman.stratiienko@globallogic.com>2019-11-06 15:14:45 +0200
commitf63726cabf3f1c940230e7b96fd514fca6dfb906 (patch)
tree180e3ff70a8d877c4ef0386b48d22363bb4f4191
parent9abec035e84bd38b1ff03c8077f6bb40c9fc75b8 (diff)
downloaddrm_hwcomposer-f63726cabf3f1c940230e7b96fd514fca6dfb906.tar.gz
drm_hwcomposer: avoid using signed errno on uint32 type
DrmGenericImporter::ConvertHalFormatToDrm() should not return negative values. - Use DRM_FORMAT_INVALID instead of -EINVAL - Check DrmGenericImporter::ConvertHalFormatToDrm() result value in DrmGenericImporter::ImportBuffer() Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
-rw-r--r--platform/platformdrmgeneric.cpp4
-rw-r--r--platform/platformhisi.cpp6
-rw-r--r--platform/platformmeson.cpp6
3 files changed, 9 insertions, 7 deletions
diff --git a/platform/platformdrmgeneric.cpp b/platform/platformdrmgeneric.cpp
index 9ac601f..f8a1858 100644
--- a/platform/platformdrmgeneric.cpp
+++ b/platform/platformdrmgeneric.cpp
@@ -89,7 +89,7 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) {
return DRM_FORMAT_YVU420;
default:
ALOGE("Cannot convert hal format to drm format %u", hal_format);
- return -EINVAL;
+ return DRM_FORMAT_INVALID;
}
}
@@ -128,6 +128,8 @@ int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
bo->height = gr_handle->height;
bo->hal_format = gr_handle->format;
bo->format = ConvertHalFormatToDrm(gr_handle->format);
+ if (bo->format == DRM_FORMAT_INVALID)
+ return -EINVAL;
bo->usage = gr_handle->usage;
bo->pixel_stride = (gr_handle->stride * 8) /
DrmFormatToBitsPerPixel(bo->format);
diff --git a/platform/platformhisi.cpp b/platform/platformhisi.cpp
index 64b410b..874a31c 100644
--- a/platform/platformhisi.cpp
+++ b/platform/platformhisi.cpp
@@ -121,9 +121,9 @@ int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
return ret;
}
- int32_t fmt = ConvertHalFormatToDrm(hnd->req_format);
- if (fmt < 0)
- return fmt;
+ uint32_t fmt = ConvertHalFormatToDrm(hnd->req_format);
+ if (fmt == DRM_FORMAT_INVALID)
+ return -EINVAL;
is_rgb = IsDrmFormatRgb(fmt);
modifiers[0] = ConvertGrallocFormatToDrmModifiers(hnd->internal_format,
diff --git a/platform/platformmeson.cpp b/platform/platformmeson.cpp
index 7bde5cd..10c2745 100644
--- a/platform/platformmeson.cpp
+++ b/platform/platformmeson.cpp
@@ -98,9 +98,9 @@ int MesonImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
return ret;
}
- int32_t fmt = ConvertHalFormatToDrm(hnd->req_format);
- if (fmt < 0)
- return fmt;
+ uint32_t fmt = ConvertHalFormatToDrm(hnd->req_format);
+ if (fmt == DRM_FORMAT_INVALID)
+ return -EINVAL;
modifiers[0] = ConvertGrallocFormatToDrmModifiers(hnd->internal_format);