mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-23 15:56:33 +00:00
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>
This commit is contained in:
parent
1f0cf2df85
commit
223a61e12e
@ -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
|
* The handler will be passed the signal number if called due to a signal, or
|
||||||
* 0 otherwise.
|
* 0 otherwise.
|
||||||
*/
|
*/
|
||||||
int igt_install_exit_handler(igt_exit_handler_t fn)
|
void igt_install_exit_handler(igt_exit_handler_t fn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < exit_handler_count; i++)
|
for (i = 0; i < exit_handler_count; i++)
|
||||||
if (exit_handler_fn[i] == fn)
|
if (exit_handler_fn[i] == fn)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
if (exit_handler_count == MAX_EXIT_HANDLERS)
|
igt_assert(exit_handler_count < MAX_EXIT_HANDLERS);
|
||||||
return -1;
|
|
||||||
|
|
||||||
exit_handler_fn[exit_handler_count] = fn;
|
exit_handler_fn[exit_handler_count] = fn;
|
||||||
exit_handler_count++;
|
exit_handler_count++;
|
||||||
|
|
||||||
if (exit_handler_count > 1)
|
if (exit_handler_count > 1)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(handled_signals); i++) {
|
for (i = 0; i < ARRAY_SIZE(handled_signals); i++) {
|
||||||
if (install_sig_handler(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))
|
if (atexit(igt_atexit_handler))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
return 0;
|
return;
|
||||||
err:
|
err:
|
||||||
restore_all_sig_handler();
|
restore_all_sig_handler();
|
||||||
exit_handler_count--;
|
exit_handler_count--;
|
||||||
|
|
||||||
return -1;
|
igt_assert_f(0, "failed to install the signal handler\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void igt_disable_exit_handler(void)
|
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)
|
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();
|
igt_disable_exit_handler();
|
||||||
orig_vt_mode = set_vt_mode(KD_GRAPHICS);
|
orig_vt_mode = set_vt_mode(KD_GRAPHICS);
|
||||||
|
@ -389,7 +389,7 @@ uint32_t drm_format_to_bpp(uint32_t drm_format);
|
|||||||
typedef void (*igt_exit_handler_t)(int sig);
|
typedef void (*igt_exit_handler_t)(int sig);
|
||||||
|
|
||||||
/* reliable atexit helpers, also work when killed by a signal (if possible) */
|
/* 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_enable_exit_handler(void);
|
||||||
void igt_disable_exit_handler(void);
|
void igt_disable_exit_handler(void);
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
|
|||||||
igt_pipe_crc_t *pipe_crc;
|
igt_pipe_crc_t *pipe_crc;
|
||||||
char buf[128];
|
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));
|
pipe_crc = calloc(1, sizeof(struct _igt_pipe_crc));
|
||||||
|
|
||||||
|
@ -1494,7 +1494,7 @@ int main(int argc, char **argv)
|
|||||||
drm_fd = drm_open_any();
|
drm_fd = drm_open_any();
|
||||||
|
|
||||||
igt_set_vt_graphics_mode();
|
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();
|
get_timestamp_format();
|
||||||
|
|
||||||
bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
|
bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user