mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-20 06:16:13 +00:00
lib/fb: Assert, instead of silently failing, when creating fbs
We were either returning 0, or a negative value cast to an unsigned int for errors and the clients of that API weren't exactly checking anything. We're in luck, we can take shortcuts in a testing library to just assert when an expected error occurs. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
parent
54397cafed
commit
50166d2a20
18
lib/igt_fb.c
18
lib/igt_fb.c
@ -396,8 +396,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
|
|||||||
* for rgb pixel formats.
|
* for rgb pixel formats.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The kms id of the created framebuffer on success or a negative error code on
|
* The kms id of the created framebuffer.
|
||||||
* failure.
|
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
igt_create_fb_with_bo_size(int fd, int width, int height,
|
igt_create_fb_with_bo_size(int fd, int width, int height,
|
||||||
@ -416,20 +415,16 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
|
|||||||
bpp = igt_drm_format_to_bpp(format);
|
bpp = igt_drm_format_to_bpp(format);
|
||||||
ret = create_bo_for_fb(fd, width, height, bpp, tiling, &fb->gem_handle,
|
ret = create_bo_for_fb(fd, width, height, bpp, tiling, &fb->gem_handle,
|
||||||
&fb->size, &fb->stride, bo_size);
|
&fb->size, &fb->stride, bo_size);
|
||||||
if (ret < 0)
|
igt_assert(ret == 0);
|
||||||
return ret;
|
|
||||||
|
|
||||||
memset(handles, 0, sizeof(handles));
|
memset(handles, 0, sizeof(handles));
|
||||||
handles[0] = fb->gem_handle;
|
handles[0] = fb->gem_handle;
|
||||||
memset(pitches, 0, sizeof(pitches));
|
memset(pitches, 0, sizeof(pitches));
|
||||||
pitches[0] = fb->stride;
|
pitches[0] = fb->stride;
|
||||||
memset(offsets, 0, sizeof(offsets));
|
memset(offsets, 0, sizeof(offsets));
|
||||||
if (drmModeAddFB2(fd, width, height, format, handles, pitches,
|
ret = drmModeAddFB2(fd, width, height, format, handles, pitches,
|
||||||
offsets, &fb_id, 0) < 0) {
|
offsets, &fb_id, 0);
|
||||||
gem_close(fd, fb->gem_handle);
|
igt_assert(ret == 0);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fb->width = width;
|
fb->width = width;
|
||||||
fb->height = height;
|
fb->height = height;
|
||||||
@ -457,8 +452,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
|
|||||||
* for rgb pixel formats.
|
* for rgb pixel formats.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The kms id of the created framebuffer on success or a negative error code on
|
* The kms id of the created framebuffer.
|
||||||
* failure.
|
|
||||||
*/
|
*/
|
||||||
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||||
unsigned int tiling, struct igt_fb *fb)
|
unsigned int tiling, struct igt_fb *fb)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user