All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Lespiau <damien.lespiau@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t] lib/fb: Assert, instead of silently failing, when creating fbs
Date: Thu, 21 Aug 2014 15:02:40 +0100	[thread overview]
Message-ID: <1408629760-20255-1-git-send-email-damien.lespiau@intel.com> (raw)

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>
---
 lib/igt_fb.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index f383970..b8448c8 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -396,8 +396,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
  * for rgb pixel formats.
  *
  * Returns:
- * The kms id of the created framebuffer on success or a negative error code on
- * failure.
+ * The kms id of the created framebuffer.
  */
 unsigned int
 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);
 	ret = create_bo_for_fb(fd, width, height, bpp, tiling, &fb->gem_handle,
 			      &fb->size, &fb->stride, bo_size);
-	if (ret < 0)
-		return ret;
+	igt_assert(ret == 0);
 
 	memset(handles, 0, sizeof(handles));
 	handles[0] = fb->gem_handle;
 	memset(pitches, 0, sizeof(pitches));
 	pitches[0] = fb->stride;
 	memset(offsets, 0, sizeof(offsets));
-	if (drmModeAddFB2(fd, width, height, format, handles, pitches,
-			  offsets, &fb_id, 0) < 0) {
-		gem_close(fd, fb->gem_handle);
-
-		return 0;
-	}
+	ret = drmModeAddFB2(fd, width, height, format, handles, pitches,
+			    offsets, &fb_id, 0);
+	igt_assert(ret == 0);
 
 	fb->width = width;
 	fb->height = height;
@@ -457,8 +452,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
  * for rgb pixel formats.
  *
  * Returns:
- * The kms id of the created framebuffer on success or a negative error code on
- * failure.
+ * The kms id of the created framebuffer.
  */
 unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
 			   unsigned int tiling, struct igt_fb *fb)
-- 
1.8.3.1

                 reply	other threads:[~2014-08-21 14:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408629760-20255-1-git-send-email-damien.lespiau@intel.com \
    --to=damien.lespiau@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.