Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 97091af

Browse files
committed
sol-log: Fix checking for NULL file and function macros
We can simplify the logic a little when printing the file and function in sol-log by imposing them to be an empty string (instead of NULL). This also solves this warning using gcc 5.3: CC build/stage/lib/common/sol-worker-thread.o CC build/stage/lib/common/sol-worker-thread-impl-posix.o ./src/lib/common/sol-log.c: In function 'sol_log_domain_init_level': ./src/lib/common/sol-log.c:63:34: warning: the address of '__PRETTY_FUNCTION__' will always evaluate as true' [-Waddress] SOL_LOG_FUNCTION ? : "", \ ^ ./src/lib/common/sol-log.c:271:5: note: in expansion of macro 'SOL_LOG_INIT_CHECK' SOL_LOG_INIT_CHECK("domain=%p", domain); ^ ./src/lib/common/sol-log.c: In function 'sol_log_vprint': ./src/lib/common/sol-log.c:63:34: warning: the address of '__PRETTY_FUNCTION__' will always evaluate as true' [-Waddress] SOL_LOG_FUNCTION ? : "", \ ^ ./src/lib/common/sol-log.c:301:5: note: in expansion of macro 'SOL_LOG_INIT_CHECK' SOL_LOG_INIT_CHECK("domain=%p, file=%s, function=%s, line=%d, fomart=%s", ^ ./src/lib/common/sol-log.c: In function 'sol_log_set_print_function': ./src/lib/common/sol-log.c:63:34: warning: the address of '__PRETTY_FUNCTION__' will always evaluate as true' [-Waddress] SOL_LOG_FUNCTION ? : "", \ ^ ./src/lib/common/sol-log.c:341:5: note: in expansion of macro 'SOL_LOG_INIT_CHECK' SOL_LOG_INIT_CHECK("cb=%p, data=%p", cb, data); ^ ./src/lib/common/sol-log.c: In function 'sol_log_level_to_str': ./src/lib/common/sol-log.c:63:34: warning: the address of '__PRETTY_FUNCTION__' will always evaluate as true' [-Waddress] SOL_LOG_FUNCTION ? : "", \ ^ ./src/lib/common/sol-log.c:369:5: note: in expansion of macro 'SOL_LOG_INIT_CHECK' SOL_LOG_INIT_CHECK("level=%hhu, buf=%p, buflen=%zd", level, buf, buflen); ^ ./src/lib/common/sol-log.c: In function 'sol_log_get_level_color': ./src/lib/common/sol-log.c:63:34: warning: the address of '__PRETTY_FUNCTION__' will always evaluate as true' [-Waddress] SOL_LOG_FUNCTION ? : "", \ ^ Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
1 parent 20e3abd commit 97091af

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/lib/common/include/sol-log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ sol_log_domain_init_level(struct sol_log_domain *domain)
472472
#ifdef SOL_LOG_FILES
473473
#define SOL_LOG_FILE __FILE__
474474
#else
475-
#define SOL_LOG_FILE NULL
475+
#define SOL_LOG_FILE ""
476476
#endif
477477

478478
/**
@@ -489,7 +489,7 @@ sol_log_domain_init_level(struct sol_log_domain *domain)
489489
#ifdef SOL_LOG_FUNCTIONS
490490
#define SOL_LOG_FUNCTION __PRETTY_FUNCTION__
491491
#else
492-
#define SOL_LOG_FUNCTION NULL
492+
#define SOL_LOG_FUNCTION ""
493493
#endif
494494

495495
/**

src/lib/common/sol-log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static bool _inited = false;
5858
if (SOL_UNLIKELY(!_inited)) { \
5959
fprintf(stderr, "CRITICAL:%s:%d:%s() " \
6060
"SOL_LOG used before initialization. "fmt "\n", \
61-
SOL_LOG_FILE ? : "", \
61+
SOL_LOG_FILE, \
6262
__LINE__, \
63-
SOL_LOG_FUNCTION ? : "", \
63+
SOL_LOG_FUNCTION, \
6464
## __VA_ARGS__); \
6565
abort(); \
6666
} \

0 commit comments

Comments
 (0)