[PATCH 3/3] lib: make igt_install_exit_handler never fail

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

 



Most callers didn't bother checking, so just move the asserts into
the function itself.

Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
 lib/drmtest.c     | 15 +++++++--------
 lib/drmtest.h     |  2 +-
 lib/igt_debugfs.c |  2 +-
 tests/.gitignore  |  1 +
 tests/kms_flip.c  |  2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 5887595..4285e27 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -2006,22 +2006,21 @@ static void fatal_sig_handler(int sig)
  * The handler will be passed the signal number if called due to a signal, or
  * 0 otherwise.
  */
-int igt_install_exit_handler(igt_exit_handler_t fn)
+void igt_install_exit_handler(igt_exit_handler_t fn)
 {
 	int i;
 
 	for (i = 0; i < exit_handler_count; i++)
 		if (exit_handler_fn[i] == fn)
-			return 0;
+			return;
 
-	if (exit_handler_count == MAX_EXIT_HANDLERS)
-		return -1;
+	igt_assert(exit_handler_count < MAX_EXIT_HANDLERS);
 
 	exit_handler_fn[exit_handler_count] = fn;
 	exit_handler_count++;
 
 	if (exit_handler_count > 1)
-		return 0;
+		return;
 
 	for (i = 0; i < ARRAY_SIZE(handled_signals); i++) {
 		if (install_sig_handler(handled_signals[i],
@@ -2032,12 +2031,12 @@ int igt_install_exit_handler(igt_exit_handler_t fn)
 	if (atexit(igt_atexit_handler))
 		goto err;
 
-	return 0;
+	return;
 err:
 	restore_all_sig_handler();
 	exit_handler_count--;
 
-	return -1;
+	igt_assert_f(0, "failed to install the signal handler\n");
 }
 
 void igt_disable_exit_handler(void)
@@ -2112,7 +2111,7 @@ static void restore_vt_mode_at_exit(int sig)
 
 void igt_set_vt_graphics_mode(void)
 {
-	do_or_die(igt_install_exit_handler(restore_vt_mode_at_exit));
+	igt_install_exit_handler(restore_vt_mode_at_exit);
 
 	igt_disable_exit_handler();
 	orig_vt_mode = set_vt_mode(KD_GRAPHICS);
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 5b35545..a9fd0bc 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -399,7 +399,7 @@ uint32_t drm_format_to_bpp(uint32_t drm_format);
 typedef void (*igt_exit_handler_t)(int sig);
 
 /* reliable atexit helpers, also work when killed by a signal (if possible) */
-int igt_install_exit_handler(igt_exit_handler_t fn);
+void igt_install_exit_handler(igt_exit_handler_t fn);
 void igt_enable_exit_handler(void);
 void igt_disable_exit_handler(void);
 
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index b41db12..2364565 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -210,7 +210,7 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 	igt_pipe_crc_t *pipe_crc;
 	char buf[128];
 
-	do_or_die(igt_install_exit_handler(pipe_crc_exit_handler));
+	igt_install_exit_handler(pipe_crc_exit_handler);
 
 	pipe_crc = calloc(1, sizeof(struct _igt_pipe_crc));
 
diff --git a/tests/.gitignore b/tests/.gitignore
index 294123c..6fcb872 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -98,6 +98,7 @@ getstats
 getversion
 igt_fork_helper
 kms_addfb
+kms_cursor_crc
 kms_flip
 kms_render
 kms_setmode
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index e8d3e22..3583bb9 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1494,7 +1494,7 @@ int main(int argc, char **argv)
 		drm_fd = drm_open_any();
 
 		igt_set_vt_graphics_mode();
-		do_or_die(igt_install_exit_handler(kms_flip_exit_handler));
+		igt_install_exit_handler(kms_flip_exit_handler);
 		get_timestamp_format();
 
 		bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
-- 
1.8.4.rc3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://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