From f89cbd0019393ed8aeefa8b633e330982c8ab126 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 30 Aug 2019 00:46:13 +0200 Subject: OSMO_SOCKADDR_STR_FMT_ARGS: guard against NULL pointer The pointless '(R)->ip?' condition of the previous commit made me want to protect against R == NULL instead. Change-Id: Ie2f47ad8ae585aaf67a6476c67f8e014820a72bc --- include/osmocom/core/sockaddr_str.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/osmocom/core/sockaddr_str.h b/include/osmocom/core/sockaddr_str.h index 7c01732d..d16dc86f 100644 --- a/include/osmocom/core/sockaddr_str.h +++ b/include/osmocom/core/sockaddr_str.h @@ -62,7 +62,7 @@ struct osmo_sockaddr_str { * printf("got " OSMO_SOCKADDR_STR_FMT "\n", OSMO_SOCKADDR_STR_FMT_ARGS(my_sockaddr_str)); */ #define OSMO_SOCKADDR_STR_FMT "%s:%u" -#define OSMO_SOCKADDR_STR_FMT_ARGS(R) (R)->ip, (R)->port +#define OSMO_SOCKADDR_STR_FMT_ARGS(R) ((R)? (R)->ip : "NULL"), ((R)? (R)->port : 0) bool osmo_sockaddr_str_is_set(const struct osmo_sockaddr_str *sockaddr_str); -- cgit v1.2.3