From patchwork Tue Jan 13 13:33:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5620461 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 30E6D9F3A0 for ; Tue, 13 Jan 2015 13:34:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 149CC20265 for ; Tue, 13 Jan 2015 13:34:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EE5D62025A for ; Tue, 13 Jan 2015 13:34:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61A166E46E; Tue, 13 Jan 2015 05:34:02 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id F3E326E46E for ; Tue, 13 Jan 2015 05:34:00 -0800 (PST) Received: by mail-wg0-f43.google.com with SMTP id k14so2960353wgh.2 for ; Tue, 13 Jan 2015 05:34:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=/2tNkodbq1RIZx6GdQcv+xa7i5Ond+YNcTl8H0hLUn8=; b=du4SszBG5d35oadpDywBK9A6wwX525ar9odGgUBmACoIG7jucSrdzjVxi3CgPi7B5f 4mMMdvHNFNb4ohyADx4Jx/XdECF06rahV4B2gKMdRyPGgrQ/kzaP+DoPtbnEjcz5kN3s Nrl7qgbw+fEvUiwlKgUVvTuMljnCvqti1GnM6cAF7HlJHF6DGGdqaafxtQwlMZae7i0i od56WsYdzxWs8h+Hrq8WW5XSDwlLs1ANH7lX9SdpJyu0d/HwEQ6IKpkeZRfUVMe9o7Ti qHm4u8yXdz8nzkmsqPZTpjO/zuLSDy7PgZYiq4Q14M6XOggPHdcQTlQ+bSsiSpEXogO+ wsdg== X-Gm-Message-State: ALoCoQmv6SahEfzewM7d9XYvC5KGldH/TQygT4Vq+rnxTVxi6Y7pfArI1UiVD0JnvYDoeY5Qr3Nj X-Received: by 10.180.211.195 with SMTP id ne3mr32289120wic.52.1421156040042; Tue, 13 Jan 2015 05:34:00 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id mo12sm25744200wjc.35.2015.01.13.05.33.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2015 05:33:59 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Tue, 13 Jan 2015 13:33:57 +0000 Message-Id: <1421156037-6305-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 Subject: [Intel-gfx] [PATCH i-g-t] lib: remove unnecessary checks on the drm_open_any return value X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP drm_open_any always returns a valid file descriptor, so there is no need to check the return value. Signed-off-by: Thomas Wood --- lib/drmtest.c | 6 +++--- lib/igt.cocci | 14 ++++++++++++++ tests/gem_alive.c | 2 -- tests/gem_flink_race.c | 2 -- tests/gem_reset_stats.c | 11 ----------- tests/gem_seqno_wrap.c | 1 - tests/prime_self_import.c | 2 -- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 813c315..133a153 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -302,10 +302,10 @@ static void quiescent_gpu_at_exit_render(int sig) /** * drm_open_any: * - * Open an i915 drm legacy device node. + * Open an i915 drm legacy device node. This function always returns a valid + * file descriptor. * - * Returns: - * The i915 drm file descriptor or -1 on error + * Returns: a i915 drm file descriptor */ int drm_open_any(void) { diff --git a/lib/igt.cocci b/lib/igt.cocci index 0d337bf..fd4ad25 100644 --- a/lib/igt.cocci +++ b/lib/igt.cocci @@ -127,3 +127,17 @@ expression b; - ((a) >= (b) ? (a) : (b)) + max(a, b) ) + +// drm_open_any always returns a valid file descriptor +@@ +expression a; +@@ +a = drm_open_any(); +( +- igt_assert(a >= 0); +| +- if (a < 0) { +- ... +- return ...; +- } +) diff --git a/tests/gem_alive.c b/tests/gem_alive.c index f87b1cb..d2bcf2a 100644 --- a/tests/gem_alive.c +++ b/tests/gem_alive.c @@ -15,8 +15,6 @@ int main(void) signal(SIGALRM, SIG_IGN); fd = drm_open_any(); - if (fd < 0) - return IGT_EXIT_SKIP; alarm(1); if (ioctl(fd, DRM_IOCTL_I915_GEM_SW_FINISH, &arg) == 0) diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c index c2a5d81..26f3258 100644 --- a/tests/gem_flink_race.c +++ b/tests/gem_flink_race.c @@ -103,7 +103,6 @@ static void test_flink_name(void) threads = calloc(num_threads, sizeof(pthread_t)); fd = drm_open_any(); - igt_assert(fd >= 0); for (i = 0; i < num_threads; i++) { r = pthread_create(&threads[i], NULL, @@ -173,7 +172,6 @@ static void test_flink_close(void) threads = calloc(num_threads, sizeof(pthread_t)); fd = drm_open_any(); - igt_assert(fd >= 0); for (i = 0; i < num_threads; i++) { r = pthread_create(&threads[i], NULL, diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index ab8728a..646d6da 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -520,10 +520,8 @@ static void test_ban(void) struct local_drm_i915_reset_stats rs_bad, rs_good; fd_bad = drm_open_any(); - igt_assert(fd_bad >= 0); fd_good = drm_open_any(); - igt_assert(fd_good >= 0); assert_reset_status(fd_bad, 0, RS_NO_ERROR); assert_reset_status(fd_good, 0, RS_NO_ERROR); @@ -609,7 +607,6 @@ static void test_ban_ctx(void) struct local_drm_i915_reset_stats rs_bad, rs_good; fd = drm_open_any(); - igt_assert(fd >= 0); assert_reset_status(fd, 0, RS_NO_ERROR); @@ -749,7 +746,6 @@ static void test_close_pending_ctx(void) uint32_t ctx; fd = drm_open_any(); - igt_assert(fd >= 0); ctx = context_create(fd); assert_reset_status(fd, ctx, RS_NO_ERROR); @@ -768,7 +764,6 @@ static void test_close_pending(void) int fd, h; fd = drm_open_any(); - igt_assert(fd >= 0); assert_reset_status(fd, 0, RS_NO_ERROR); @@ -831,7 +826,6 @@ static void test_close_pending_fork(const bool reverse) int fd, h; fd = drm_open_any(); - igt_assert(fd >= 0); assert_reset_status(fd, 0, RS_NO_ERROR); @@ -871,7 +865,6 @@ static void test_close_pending_fork(const bool reverse) /* Then we just wait on hang to happen */ fd = drm_open_any(); - igt_assert(fd >= 0); h = exec_valid(fd, 0); igt_assert(h >= 0); @@ -887,7 +880,6 @@ static void test_reset_count(const bool create_ctx) long c1, c2; fd = drm_open_any(); - igt_assert(fd >= 0); if (create_ctx) ctx = context_create(fd); else @@ -998,7 +990,6 @@ static void test_params_ctx(void) int fd, ctx; fd = drm_open_any(); - igt_assert(fd >= 0); ctx = context_create(fd); _test_param(fd, ctx); @@ -1011,7 +1002,6 @@ static void test_params(void) int fd; fd = drm_open_any(); - igt_assert(fd >= 0); _test_param(fd, 0); @@ -1025,7 +1015,6 @@ static void defer_hangcheck(int ring_num) int seconds = 30; const struct target_ring *next_ring; fd = drm_open_any(); - igt_assert(fd >= 0); do { next_ring = &rings[(++ring_num) % NUM_RINGS]; diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c index 7da7fdf..42493ef 100644 --- a/tests/gem_seqno_wrap.c +++ b/tests/gem_seqno_wrap.c @@ -187,7 +187,6 @@ static void run_sync_test(int num_buffers, bool verify) struct igt_buf *s_src, *s_dst; fd = drm_open_any(); - igt_assert(fd >= 0); gem_quiescent_gpu(fd); diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c index 9cb0780..1eb5a04 100644 --- a/tests/prime_self_import.c +++ b/tests/prime_self_import.c @@ -269,7 +269,6 @@ static void test_reimport_close_race(void) threads = calloc(num_threads, sizeof(pthread_t)); fds[0] = drm_open_any(); - igt_assert(fds[0] >= 0); handle = gem_create(fds[0], BO_SIZE); @@ -349,7 +348,6 @@ static void test_export_close_race(void) threads = calloc(num_threads, sizeof(pthread_t)); fd = drm_open_any(); - igt_assert(fd >= 0); obj_count = get_object_count();