diff mbox

compiler warning: unconstify arg passed to OCTET_STRING_noalloc()

Message ID 1460646327-23854-1-git-send-email-nhofmeyr@sysmocom.de
State Not Applicable
Headers show

Commit Message

Neels Hofmeyr April 14, 2016, 3:05 p.m. UTC
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 mbox

Patch

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);