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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Thu Aug 29 22:51:12 UTC 2019


neels has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/15341/1

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: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190829/339ab8b7/attachment.htm>


More information about the gerrit-log mailing list