From patchwork Mon Aug 14 09:32:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9898417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D907B60230 for ; Mon, 14 Aug 2017 09:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC7492859A for ; Mon, 14 Aug 2017 09:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C18562859F; Mon, 14 Aug 2017 09:32:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79E142859A for ; Mon, 14 Aug 2017 09:32:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED23E6E110; Mon, 14 Aug 2017 09:32:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE36E6E109 for ; Mon, 14 Aug 2017 09:32:19 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id y206so13752336wmd.5 for ; Mon, 14 Aug 2017 02:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iyqD4G38pgt2Fuv0h3lO2A9xOYUpj6U/nbZ6Qwf0RpU=; b=kwo3tqOJ9lpT68YNI8GqruAeYqb5smv/Ez6vWYYhOvE6rAwFzXb8AuxecX9+4Z31ua rP84L6I9up5MjPn8MksGc0uzsH1drTuYjPHElUXWRtLWi1DAO+AExJPkbs8+8vIDDWXc e6RmAdTqQP/0cjFFkmXRXCN10yeUyCefClSX4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iyqD4G38pgt2Fuv0h3lO2A9xOYUpj6U/nbZ6Qwf0RpU=; b=pVikqVZpZpIaJiUNG/bL8Rj7gRtO1I2csFdnophIYDNaPJnFkcEDYxVKIfMNIa8kMl hPl2DRwM1qg5+3aJYA5aNxF4+NWfhPwKjlcwUx7N/S5e7DrZ5CegkSFTA11EnOKlhCPh sXkI2lk1jovaQ8TbKpYGtuvDraimvsi79erluYxeY7FYJ1j6kZEuartN72PIuBh9cJAZ D6BKdI6WtuSjW8DR7hNm90AGhIOijuc5dm/pLy2pYKV+iI9o/QQMLh5iksXXKW7p0R/K 5R1iE1/0Z1Q5bXS/4ybt5RdLUF7Ejxpl2Q6EvRRMSe+uhUdWoEQaHeIN9x8Pdch8VDgF 0eoQ== X-Gm-Message-State: AHYfb5jzbKsOizIwC4GoIKN9KcA3j5CWW6MhawijP1hKeQV3MmmuvQDS oJX0/BZ9rwthvTu6mQs= X-Received: by 10.80.146.168 with SMTP id k37mr23936423eda.23.1502703137871; Mon, 14 Aug 2017 02:32:17 -0700 (PDT) Received: from wespe.ffwll.local ([2a02:168:56e6:0:6631:50ff:fe8d:fd2e]) by smtp.gmail.com with ESMTPSA id i23sm3454910edj.13.2017.08.14.02.32.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 02:32:16 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Mon, 14 Aug 2017 11:32:07 +0200 Message-Id: <1502703127-6792-4-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1502703127-6792-1-git-send-email-daniel.vetter@ffwll.ch> References: <1502703127-6792-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Daniel Stone Subject: [Intel-gfx] [PATCH i-g-t 4/4] lib/kms: Check usage of for_each_* 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-Virus-Scanned: ClamAV using ClamSMTP Except for for_each_pipe_static they cannot be used outside of fixtures/subtest. Assert this. This will make the broken version of kms_ccs assert when run, which also would have made $make check fail. Cc: Daniel Stone Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- lib/igt_kms.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/igt_kms.h b/lib/igt_kms.h index b28fe8c564c5..96713c24b624 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -457,7 +458,7 @@ static inline bool igt_output_is_connected(igt_output_t *output) * This for loop iterates over all outputs. */ #define for_each_connected_output(display, output) \ - for (int i__ = 0; i__ < (display)->n_outputs; i__++) \ + for (int i__ = 0; assert(igt_can_fail()), i__ < (display)->n_outputs; i__++) \ for_each_if (((output = &(display)->outputs[i__]), \ igt_output_is_connected(output))) @@ -485,7 +486,7 @@ static inline bool igt_output_is_connected(igt_output_t *output) * Used #for_each_pipe_static instead. */ #define for_each_pipe(display, pipe) \ - for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++) + for (pipe = 0; assert(igt_can_fail()), pipe < igt_display_get_n_pipes(display); pipe++) /** * for_each_pipe_with_valid_output: @@ -498,7 +499,7 @@ static inline bool igt_output_is_connected(igt_output_t *output) */ #define for_each_pipe_with_valid_output(display, pipe, output) \ for (int con__ = pipe = 0; \ - pipe < igt_display_get_n_pipes((display)) && con__ < (display)->n_outputs; \ + assert(igt_can_fail()), pipe < igt_display_get_n_pipes((display)) && con__ < (display)->n_outputs; \ con__ = (con__ + 1 < (display)->n_outputs) ? con__ + 1 : (pipe = pipe + 1, 0)) \ for_each_if (((output = &(display)->outputs[con__]), \ igt_pipe_connector_valid(pipe, output))) @@ -518,7 +519,7 @@ static inline bool igt_output_is_connected(igt_output_t *output) for_each_if (igt_pipe_connector_valid(pipe, output)) #define for_each_plane_on_pipe(display, pipe, plane) \ - for (int j__ = 0; (plane) = &(display)->pipes[(pipe)].planes[j__], \ + for (int j__ = 0; assert(igt_can_fail()), (plane) = &(display)->pipes[(pipe)].planes[j__], \ j__ < (display)->pipes[(pipe)].n_planes; j__++) #define IGT_FIXED(i,f) ((i) << 16 | (f))