Skip to content

Commit a74f4fb

Browse files
committed
coverity: attempt to model clar's assertions
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.
1 parent 50d4688 commit a74f4fb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

script/user_model.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,26 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
7373
buf->size = len + 1;
7474
return 0;
7575
}
76+
77+
void clar__fail(
78+
const char *file,
79+
int line,
80+
const char *error,
81+
const char *description,
82+
int should_abort)
83+
{
84+
if (should_abort)
85+
__coverity_panic__();
86+
}
87+
88+
void clar__assert(
89+
int condition,
90+
const char *file,
91+
int line,
92+
const char *error,
93+
const char *description,
94+
int should_abort)
95+
{
96+
if (!condition && should_abort)
97+
__coverity_panic__();
98+
}

0 commit comments

Comments
 (0)