[PATCH i-g-t 4/4] lib/kms: Check usage of for_each_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <daniels@xxxxxxxxxxxxx>
Cc: Jason Ekstrand <jason@xxxxxxxxxxxxxx>
Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
 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 <stdbool.h>
 #include <stdint.h>
 #include <stddef.h>
+#include <assert.h>
 
 #include <xf86drmMode.h>
 
@@ -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))
-- 
2.5.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux