Change in ...libosmocore[master]: OSMO_SOCKADDR_STR_FMT_ARGS: guard against NULL pointer

laforge gerrit-no-reply at lists.osmocom.org
Fri Aug 30 20:24:37 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/libosmocore/+/15341 )

Change subject: OSMO_SOCKADDR_STR_FMT_ARGS: guard against NULL pointer
......................................................................

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
---
M include/osmocom/core/sockaddr_str.h
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/include/osmocom/core/sockaddr_str.h b/include/osmocom/core/sockaddr_str.h
index 7c01732..d16dc86 100644
--- a/include/osmocom/core/sockaddr_str.h
+++ b/include/osmocom/core/sockaddr_str.h
@@ -62,7 +62,7 @@
  *     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);
 

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15341
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie2f47ad8ae585aaf67a6476c67f8e014820a72bc
Gerrit-Change-Number: 15341
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190830/b8e235b3/attachment.html>


More information about the gerrit-log mailing list