pespin has uploaded this change for review.

View Change

tlv.h: Fix TLVP_PRESENT returning a pointer instead of a boolean

I was warned by gcc about comparing a pointer with an integer when using
TLVP_PRESENT with something like:
bool expect = ...;
if (expect != TLV_PRESENT(...))

That's indeed dangerous because TLV_PRESENT is considered to return a
boolean, as opposite to TLV_VAL.

Change-Id: I45cc2745c695e30c37b10f592903ec3775a55492
---
M include/osmocom/gsm/tlv.h
1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/88/28988/1
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index 6d0008f..fd6659c 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -543,7 +543,7 @@
int tlv_encode_ordered(struct msgb *msg, const struct tlv_definition *def, const struct tlv_parsed *tp,
const uint8_t *tag_order, unsigned int tag_order_len);

-#define TLVP_PRESENT(x, y) ((x)->lv[y].val)
+#define TLVP_PRESENT(x, y) (!!((x)->lv[y].val))
#define TLVP_LEN(x, y) (x)->lv[y].len
#define TLVP_VAL(x, y) (x)->lv[y].val


To view, visit change 28988. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I45cc2745c695e30c37b10f592903ec3775a55492
Gerrit-Change-Number: 28988
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange