[PATCH] compiler warning: unconstify arg passed to OCTET_STRING_noalloc()

Neels Hofmeyr nhofmeyr at sysmocom.de
Thu Apr 14 15:05:27 UTC 2016


This is after the patch to libasn1c, removing str arg constness.
Note the comment added in the code.
---
 src/ranap_msg_factory.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index bdae92e..e87eeaf 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -180,8 +180,13 @@ struct msgb *ranap_new_msg_dt(uint8_t sapi, const uint8_t *nas, unsigned int nas
 	else
 		ies.sapi = RANAP_SAPI_sapi_0;
 
-	/* Avoid copying + later freeing of OCTET STRING */
-	OCTET_STRING_noalloc(&ies.nas_pdu, nas, nas_len);
+	/*
+	 * Avoid copying + later freeing of OCTET STRING.
+	 * To store the pointer in an OCTET_STRING_t without copying, we need
+	 * to un-const *nas. Note: un-consting *nas is safe because ies.nas_pdu
+	 * is only used to store the IEs in dt.
+	 */
+	OCTET_STRING_noalloc(&ies.nas_pdu, (uint8_t*)nas, nas_len);
 
 	/* ies -> dt */
 	rc = ranap_encode_directtransferies(&dt, &ies);
-- 
2.1.4




More information about the OpenBSC mailing list