[libasn1c PATCH] src: avoid pointer casting warnings.

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/OpenBSC@lists.osmocom.org/.

Diego Elio Pettenò flameeyes at flameeyes.eu
Thu Jul 5 10:09:59 UTC 2012


These easily cause safety checks to go off as they can represent
64-bit-unsafe code, but in this case they are minor changes required.

Signed-off-by: Diego Elio Pettenò <flameeyes at flameeyes.eu>
---
 src/constr_SET_OF.c |    2 +-
 src/per_support.c   |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/constr_SET_OF.c b/src/constr_SET_OF.c
index 11eac57..8e376e6 100644
--- a/src/constr_SET_OF.c
+++ b/src/constr_SET_OF.c
@@ -915,7 +915,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
 			nelems = uper_get_length(pd,
 				ct ? ct->effective_bits : -1, &repeat);
 			ASN_DEBUG("Got to decode %d elements (eff %d)",
-				(int)nelems, (int)ct ? ct->effective_bits : -1);
+				(int)nelems, ct != NULL ? ct->effective_bits : -1);
 			if(nelems < 0) _ASN_DECODE_STARVED;
 		}
 
diff --git a/src/per_support.c b/src/per_support.c
index 173e696..e891a0e 100644
--- a/src/per_support.c
+++ b/src/per_support.c
@@ -13,9 +13,9 @@ per_data_string(asn_per_data_t *pd) {
 	static int n;
 	n = (n+1) % 2;
 	snprintf(buf[n], sizeof(buf),
-		"{m=%d span %+d[%d..%d] (%d)}",
+		"{m=%zu span %+d[%zu..%zu] (%zu)}",
 		pd->moved,
-		(((int)pd->buffer) & 0xf),
+		 (int)(((ptrdiff_t)pd->buffer) & 0xf),
 		pd->nboff, pd->nbits,
 		pd->nbits - pd->nboff);
 	return buf[n];
@@ -106,7 +106,7 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
 	ASN_DEBUG("  [PER got %2d<=%2d bits => span %d %+d[%d..%d]:%02x (%d) => 0x%x]",
 		nbits, nleft,
 		pd->moved,
-		(((int)pd->buffer) & 0xf),
+		(((ptrdiff_t)pd->buffer) & 0xf),
 		pd->nboff, pd->nbits,
 		pd->buffer[0],
 		pd->nbits - pd->nboff,
-- 
1.7.8.6





More information about the OpenBSC mailing list