[asterisk-commits] rmudgett: trunk r378823 - in /trunk: include/asterisk/test.h main/test.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 9 16:15:45 CST 2013


Author: rmudgett
Date: Wed Jan  9 16:15:41 2013
New Revision: 378823

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378823
Log:
Tweaked __ast_test_suite_assert_notify() and __ast_test_suite_event_notify() to be void functions.

Modified:
    trunk/include/asterisk/test.h
    trunk/main/test.c

Modified: trunk/include/asterisk/test.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/test.h?view=diff&rev=378823&r1=378822&r2=378823
==============================================================================
--- trunk/include/asterisk/test.h (original)
+++ trunk/include/asterisk/test.h Wed Jan  9 16:15:41 2013
@@ -145,10 +145,9 @@
  * \param state		The state the application has changed to
  * \param fmt		The message with format parameters to add to the manager event
  *
- * \returns 0 on success
- * \returns any other value on failure
- */
-int __ast_test_suite_event_notify(const char *file, const char *func, int line, const char *state, const char *fmt, ...)
+ * \return Nothing
+ */
+void __ast_test_suite_event_notify(const char *file, const char *func, int line, const char *state, const char *fmt, ...)
 	__attribute__((format(printf, 5, 6)));
 
 /*!
@@ -161,10 +160,9 @@
  *
  * \param exp	The expression to evaluate
  *
- * \returns 0 on success
- * \returns any other value on failure
- */
-int __ast_test_suite_assert_notify(const char *file, const char *func, int line, const char *exp);
+ * \return Nothing
+ */
+void __ast_test_suite_assert_notify(const char *file, const char *func, int line, const char *exp);
 
 /*!
  * \ref __ast_test_suite_event_notify()
@@ -175,13 +173,17 @@
 /*!
  * \ref __ast_test_suite_assert_notify()
  */
-#define ast_test_suite_assert(exp) \
-	( (exp) ? (void)0 : __ast_test_suite_assert_notify(__FILE__, __PRETTY_FUNCTION__, __LINE__, #exp))
+#define ast_test_suite_assert(exp)				\
+	do {										\
+		if (__builtin_expect(!(exp), 1)) {		\
+			__ast_test_suite_assert_notify(__FILE__, __PRETTY_FUNCTION__, __LINE__, #exp); \
+		}										\
+	} while (0)
 
 #else
 
-#define ast_test_suite_event_notify(s, f, ...) (void)0;
-#define ast_test_suite_assert(exp) (void)0;
+#define ast_test_suite_event_notify(s, f, ...)
+#define ast_test_suite_assert(exp)
 
 #endif
 

Modified: trunk/main/test.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/test.c?view=diff&rev=378823&r1=378822&r2=378823
==============================================================================
--- trunk/main/test.c (original)
+++ trunk/main/test.c Wed Jan  9 16:15:41 2013
@@ -910,13 +910,13 @@
 	AST_CLI_DEFINE(test_cli_generate_results,          "generate test results to file"),
 };
 
-int __ast_test_suite_event_notify(const char *file, const char *func, int line, const char *state, const char *fmt, ...)
+void __ast_test_suite_event_notify(const char *file, const char *func, int line, const char *state, const char *fmt, ...)
 {
 	struct ast_str *buf = NULL;
 	va_list ap;
 
 	if (!(buf = ast_str_create(128))) {
-		return -1;
+		return;
 	}
 
 	va_start(ap, fmt);
@@ -933,11 +933,9 @@
 		state, file, func, line, ast_str_buffer(buf));
 
 	ast_free(buf);
-
-	return 0;
-}
-
-int __ast_test_suite_assert_notify(const char *file, const char *func, int line, const char *exp)
+}
+
+void __ast_test_suite_assert_notify(const char *file, const char *func, int line, const char *exp)
 {
 	manager_event(EVENT_FLAG_TEST, "TestEvent",
 		"Type: Assert\r\n"
@@ -946,8 +944,6 @@
 		"AppLine: %d\r\n"
 		"Expression: %s\r\n",
 		file, func, line, exp);
-
-	return 0;
 }
 
 #endif /* TEST_FRAMEWORK */




More information about the asterisk-commits mailing list