Skip to content

Commit

Permalink
coverity: attempt to model clar's assertions
Browse files Browse the repository at this point in the history
Coverity considers that anything that looks like assert() behaves like
it (ie. side-effects would be skipped on a NDEBUG build). As we have a
bunch of those in the test suite (128), this would ensure Coverity isn't
confused.
  • Loading branch information
tiennou committed Jan 4, 2019
1 parent 50d4688 commit a74f4fb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions script/user_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,26 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
buf->size = len + 1;
return 0;
}

void clar__fail(
const char *file,
int line,
const char *error,
const char *description,
int should_abort)
{
if (should_abort)
__coverity_panic__();
}

void clar__assert(
int condition,
const char *file,
int line,
const char *error,
const char *description,
int should_abort)
{
if (!condition && should_abort)
__coverity_panic__();
}

0 comments on commit a74f4fb

Please sign in to comment.