From b7d63c073373ac0049d4266a375a7c15e595f7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jere=20Lepp=C3=A4nen?= Date: Thu, 23 Mar 2023 19:34:28 +0200 Subject: helper: debug: reduce code duplication in ODPH_LOG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Call fprintf() in just one place in ODPH_LOG. As a nice side effect, print format warnings also appear just once, instead of three times. Signed-off-by: Jere Leppänen Reviewed-by: Tuomas Taipale --- helper/include/odp/helper/odph_debug.h | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'helper') diff --git a/helper/include/odp/helper/odph_debug.h b/helper/include/odp/helper/odph_debug.h index 20ba3d04b..157f765d6 100644 --- a/helper/include/odp/helper/odph_debug.h +++ b/helper/include/odp/helper/odph_debug.h @@ -63,25 +63,11 @@ typedef enum odph_log_level { */ #define ODPH_LOG(level, fmt, ...) \ do { \ - switch (level) { \ - case ODPH_LOG_ERR: \ + if (level != ODPH_LOG_DBG || ODPH_DEBUG_PRINT == 1) \ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__); \ - break; \ - case ODPH_LOG_DBG: \ - if (ODPH_DEBUG_PRINT == 1) \ - fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ - break; \ - case ODPH_LOG_ABORT: \ - fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ + if (level == ODPH_LOG_ABORT) \ abort(); \ - break; \ - default: \ - fprintf(stderr, "Unknown LOG level"); \ - break;\ - } \ } while (0) /** -- cgit v1.2.3