diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-08-08 17:35:07 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2022-08-08 20:07:15 +0000 |
commit | 862dd363180f09d975f13030049d34d29bc96d70 (patch) | |
tree | 91db0a2a4947c9e253c367596fc6ec1106272970 | |
parent | 6960b6a8556804fe839f450e6471d25b8e911895 (diff) |
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
-rw-r--r-- | include/osmocom/gsm/tlv.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index 6d0008f2..fd6659c6 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -543,7 +543,7 @@ int tlv_encode(struct msgb *msg, const struct tlv_definition *def, const struct 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 |