Skip to content

Commit

Permalink
Fixed invalid setjmp usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Snaipe committed Sep 18, 2015
1 parent bf51b3a commit f8e2054
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/core/abort.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

jmp_buf g_pre_test;

int setup_abort_test(void) {
return !setjmp(g_pre_test);
}

void criterion_abort_test(void) {
longjmp(g_pre_test, 1);
}
2 changes: 0 additions & 2 deletions src/core/abort.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@

extern jmp_buf g_pre_test;

int setup_abort_test(void);

#endif /* !ABORT_H_ */
16 changes: 9 additions & 7 deletions src/core/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ TestSuite();
Test(,) {};

static INLINE void nothing(void) {}
static INLINE void nothing_ptr(UNUSED void* ptr) {}

int cmp_suite(void *a, void *b) {
struct criterion_suite *s1 = a, *s2 = b;
Expand Down Expand Up @@ -185,13 +184,16 @@ static void run_test_child(struct criterion_test *test,
send_event(PRE_TEST, NULL, 0);

struct timespec_compat ts;
if (setup_abort_test()) {
if (!setjmp(g_pre_test)) {
timer_start(&ts);
if (!test->data->param_)
(test->test ? test->test : nothing)();
else
(test->test ? (void(*)(void*)) test->test
: nothing_ptr)(g_worker_context.param->ptr);
if (test->test) {
if (!test->data->param_) {
test->test();
} else {
void(*param_test_func)(void *) = (void(*)(void*)) test->test;
param_test_func(g_worker_context.param->ptr);
}
}
}

double elapsed_time;
Expand Down

0 comments on commit f8e2054

Please sign in to comment.