summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-10-31 17:16:33 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-11-01 21:10:59 +0100
commit223a61e12e119d96484ed05c563d1781fd613a4e (patch)
tree5932dca87d2165b363dab524f66002979024996a /lib
parent1f0cf2df85ca3f9d900b21db9c8744a99e8f60a0 (diff)
lib: make igt_install_exit_handler never fail
Most callers didn't bother checking, so just move the asserts into the function itself. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c15
-rw-r--r--lib/drmtest.h2
-rw-r--r--lib/igt_debugfs.c2
3 files changed, 9 insertions, 10 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 50b5aac0..e3fc166e 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -2007,22 +2007,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],
@@ -2033,12 +2032,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)
@@ -2113,7 +2112,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 6e8b16b5..be0632f4 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -389,7 +389,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 7d710e24..0319effc 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -212,7 +212,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));