check/check-0.15.0-attribute-format.patch

91 lines
3.3 KiB
Diff
Raw Normal View History

diff --git a/src/check.c b/src/check.c
index f74b384..89df345 100644
--- a/src/check.c
+++ b/src/check.c
@@ -362,25 +362,24 @@ void _mark_point(const char *file, int line)
send_loc_info(file, line);
}
-void _ck_assert_failed(const char *file, int line, const char *expr, ...)
+void _ck_assert_failed(const char *file, int line, const char *expr,
+ const char *msg, ...)
{
- const char *msg;
- va_list ap;
char buf[BUFSIZ];
const char *to_send;
send_loc_info(file, line);
- va_start(ap, expr);
- msg = (const char *)va_arg(ap, char *);
-
/*
* If a message was passed, format it with vsnprintf.
* Otherwise, print the expression as is.
*/
if(msg != NULL)
{
+ va_list ap;
+ va_start(ap, msg);
vsnprintf(buf, BUFSIZ, msg, ap);
+ va_end(ap);
to_send = buf;
}
else
@@ -388,7 +387,6 @@ void _ck_assert_failed(const char *file, int line, const char *expr, ...)
to_send = expr;
}
- va_end(ap);
send_failure_info(to_send);
if(cur_fork_status() == CK_FORK)
{
diff --git a/src/check.h.in b/src/check.h.in
index fdbc8b0..9baddc9 100644
--- a/src/check.h.in
+++ b/src/check.h.in
@@ -480,7 +480,7 @@ static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)
*/
#define fail_if(expr, ...)\
(expr) ? \
- _ck_assert_failed(__FILE__, __LINE__, "Failure '"#expr"' occurred" , ## __VA_ARGS__, NULL) \
+ _ck_assert_failed(__FILE__, __LINE__, "Failure '"#expr"' occurred" , ## __VA_ARGS__) \
: _mark_point(__FILE__, __LINE__)
/*
@@ -500,11 +500,12 @@ static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)
*/
#if @HAVE_FORK@
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
- const char *expr,
- ...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(gnu_printf, 3, 4);
+ const char *expr, const char *msg,
+ ...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(gnu_printf, 4, 5);
#else
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
- const char *expr, ...) CK_ATTRIBUTE_FORMAT(gnu_printf, 3, 4);
+ const char *expr, const char *msg,
+ ...) CK_ATTRIBUTE_FORMAT(gnu_printf, 4, 5);
#endif
/**
@@ -534,7 +535,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
#define ck_assert_msg(expr, ...) \
(expr) ? \
_mark_point(__FILE__, __LINE__) : \
- _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
+ _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__)
/**
* Unconditionally fail the test
@@ -553,7 +554,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
*
* @since 0.9.6
*/
-#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL)
+#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__)
/* Signed and unsigned integer comparison macros with improved output compared to ck_assert(). */
/* OP may be any comparison operator. */