driver: display: Added asserts to write of dummy driver
Added asserts to write function of dummy display driver to check if write is within bounds Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
1130dc9f90
commit
814f94e053
1 changed files with 16 additions and 0 deletions
|
@ -29,6 +29,22 @@ static int dummy_display_write(const struct device *dev, const uint16_t x,
|
||||||
const struct display_buffer_descriptor *desc,
|
const struct display_buffer_descriptor *desc,
|
||||||
const void *buf)
|
const void *buf)
|
||||||
{
|
{
|
||||||
|
__ASSERT(desc->width <= desc->pitch, "Pitch is smaller then width");
|
||||||
|
__ASSERT(desc->pitch <= CONFIG_DUMMY_DISPLAY_X_RES,
|
||||||
|
"Pitch in descriptor is larger than screen size");
|
||||||
|
__ASSERT(desc->height <= CONFIG_DUMMY_DISPLAY_Y_RES,
|
||||||
|
"Height in descriptor is larger than screen size");
|
||||||
|
__ASSERT(x + desc->pitch <= CONFIG_DUMMY_DISPLAY_X_RES,
|
||||||
|
"Writing outside screen boundaries in horizontal direction");
|
||||||
|
__ASSERT(y + desc->height <= CONFIG_DUMMY_DISPLAY_Y_RES,
|
||||||
|
"Writing outside screen boundaries in vertical direction");
|
||||||
|
|
||||||
|
if (desc->width > desc->pitch ||
|
||||||
|
x + desc->pitch > CONFIG_DUMMY_DISPLAY_X_RES ||
|
||||||
|
y + desc->height > CONFIG_DUMMY_DISPLAY_Y_RES) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue