diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-13 03:55:06 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-18 02:38:37 +0200 |
commit | 74e4ed6f36d587d9b7d8790cddcd6902b4fe2359 (patch) | |
tree | a17684f8f7fd0d84e526373b7e5c475ae07bfd51 /tests/gsm0808 | |
parent | 8d41d722d605bc3eb2e71daea29bf21ac9031ae3 (diff) |
tlv: add TLV_GET() and TLV_GET_MINLEN()
Rationale: so far we use code like
if (TLVP_PRESENT(&tp, VERY_LONG_ENUM_VALUE_NAME_THAT_NEVER_ENDS)) {
val = TLVP_VAL(&tp, VERY_LONG_ENUM_VALUE_NAME_THAT_NEVER_ENDS);
len = TLVP_LEN(&tp, VERY_L0NG_ENUM_VALUE_NAME_TH4T_NEVER_EMDS);
}
This is a) very long and b) prone to picking the wrong name one of the three
times, which would use the wrong length or val without necessarily being
noticed. A safer and shorter, more readable pattern is:
struct tlv_p_entry *e = TVLP_GET(&tp, VERY_LONG_ENUM_VALUE_NAME_THAT_NEVER_ENDS);
if (!e)
return -ENOENT;
hexdump(e->val, e->len);
Change-Id: I445de17fc2daa3ab051f5708dd0cc185b23dc048
Diffstat (limited to 'tests/gsm0808')
0 files changed, 0 insertions, 0 deletions