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>
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 @@
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 @@
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 @@
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 @@
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);