aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Clément Tosi <ptosi@google.com>2023-04-03 14:04:58 +0100
committerPierre-Clément Tosi <ptosi@google.com>2023-04-13 09:25:59 +0100
commit89064a4e225f8037184d5244aae8389366d0a50b (patch)
treecfc3f93f845175781608a930c4b74b578d5e727a
parente9e5562114dda5a2da6e38e25ddb042494dc23d0 (diff)
downloadavb-89064a4e225f8037184d5244aae8389366d0a50b.tar.gz
util: Deprecate avb_{debug,error,fatal}v() macros
Noting that both the avb_*() and avb_*v() macros use the underlying avb_printv() function, which requires a terminating NULL sentinel, unify the 2 classes of macros to wrap the call and encapsulate the NULL argument; as the resulting macros are variadic, they now cover the single-parameter case, deprecating the need for having distinct classes of macros. As a result, keep the avb_*() macros and deprecate the avb_*v() macros, as they have a more convenient name, but keep the old macros defined, in case client code uses them. Note that this new implementation of the macros is still compatible with the (previously mandatory) use-case where a NULL sentinel needed to be passed. Test: - Change-Id: I893b7581283133bacd9c101273c00c23d8621890
-rw-r--r--libavb/avb_util.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/libavb/avb_util.h b/libavb/avb_util.h
index 09205fc..671d39a 100644
--- a/libavb/avb_util.h
+++ b/libavb/avb_util.h
@@ -44,7 +44,8 @@ extern "C" {
AVB_TO_STRING(__LINE__), \
": " level ": ", \
message, \
- ##__VA_ARGS__)
+ ##__VA_ARGS__, \
+ NULL)
#ifdef AVB_ENABLE_DEBUG
/* Aborts the program if |expr| is false.
@@ -71,16 +72,14 @@ extern "C" {
*
* These have no effect unless AVB_ENABLE_DEBUG is defined.
*/
-#define avb_debug(message) avb_debugv(message, NULL)
-#define avb_debugv(message, ...) \
+#define avb_debug(message, ...) \
do { \
AVB_LOG("DEBUG", message, ##__VA_ARGS__); \
} while (0)
#else
#define avb_assert(expr)
#define avb_assert_not_reached()
-#define avb_debug(message)
-#define avb_debugv(message, ...)
+#define avb_debug(message, ...)
#endif
/* Aborts the program if |addr| is not word-aligned.
@@ -93,21 +92,25 @@ extern "C" {
/* Prints out a message. This is typically used if a runtime-error
* occurs.
*/
-#define avb_error(message) avb_errorv(message, NULL)
-#define avb_errorv(message, ...) \
+#define avb_error(message, ...) \
do { \
AVB_LOG("ERROR", message, ##__VA_ARGS__); \
} while (0)
/* Prints out a message and calls avb_abort().
*/
-#define avb_fatal(message) avb_fatalv(message, NULL)
-#define avb_fatalv(message, ...) \
+#define avb_fatal(message, ...) \
do { \
AVB_LOG("FATAL", message, ##__VA_ARGS__); \
avb_abort(); \
} while (0)
+/* Deprecated legacy logging functions -- kept for client compatibility.
+ */
+#define avb_debugv(message, ...) avb_debug(message, ##__VA_ARGS__)
+#define avb_errorv(message, ...) avb_error(message, ##__VA_ARGS__)
+#define avb_fatalv(message, ...) avb_fatal(message, ##__VA_ARGS__)
+
/* Converts a 16-bit unsigned integer from big-endian to host byte order. */
uint16_t avb_be16toh(uint16_t in) AVB_ATTR_WARN_UNUSED_RESULT;