diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-05-24 16:02:34 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-05-25 16:52:52 -0500 |
commit | 60cab4354c9f730c09ee5ad4ef39e40c987248d8 (patch) | |
tree | 25320ed0ffb544bc9041f2cdcad3986fe8927dec | |
parent | 4dcce0304a04702abfce5adfad418248751da328 (diff) | |
download | ofono-60cab4354c9f730c09ee5ad4ef39e40c987248d8.tar.bz2 |
stkutil: Make the code more readable
-rw-r--r-- | src/stkutil.c | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/src/stkutil.c b/src/stkutil.c index 778678f8..78ebda3d 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -3039,14 +3039,21 @@ static gboolean build_dataobj_result(struct stk_tlv_builder *tlv, const void *data, gboolean cr) { const struct stk_result *result = data; + unsigned char tag = STK_DATA_OBJECT_TYPE_RESULT; - return stk_tlv_open_container(tlv, cr, STK_DATA_OBJECT_TYPE_RESULT, - FALSE) && - stk_tlv_append_byte(tlv, result->type) && - (result->additional_len == 0 || - stk_tlv_append_bytes(tlv, result->additional, - result->additional_len)) && - stk_tlv_close_container(tlv); + if (stk_tlv_open_container(tlv, cr, tag, FALSE) == FALSE) + return FALSE; + + if (stk_tlv_append_byte(tlv, result->type) == FALSE) + return FALSE; + + if (result->additional_len > 0) + if (stk_tlv_append_bytes(tlv, result->additional, + result->additional_len) == FALSE) + return FALSE; + + if (stk_tlv_close_container(tlv) == FALSE) + return FALSE; } unsigned int stk_pdu_from_response(const struct stk_response *response, @@ -3054,6 +3061,7 @@ unsigned int stk_pdu_from_response(const struct stk_response *response, { struct stk_tlv_builder builder; gboolean ok = TRUE; + unsigned char tag; stk_tlv_builder_init(&builder, pdu, size); @@ -3062,13 +3070,20 @@ unsigned int stk_pdu_from_response(const struct stk_response *response, * Command Details TLV first, followed by Device Identities TLV * and the Result TLV. Comprehension required everywhere. */ - if ((stk_tlv_open_container(&builder, TRUE, - STK_DATA_OBJECT_TYPE_COMMAND_DETAILS, - FALSE) && - stk_tlv_append_byte(&builder, response->number) && - stk_tlv_append_byte(&builder, response->type) && - stk_tlv_append_byte(&builder, response->qualifier) && - stk_tlv_close_container(&builder)) != TRUE) + tag = STK_DATA_OBJECT_TYPE_COMMAND_DETAILS; + if (stk_tlv_open_container(&builder, TRUE, tag, FALSE) == FALSE) + return 0; + + if (stk_tlv_append_byte(&builder, response->number) == FALSE) + return 0; + + if (stk_tlv_append_byte(&builder, response->type) == FALSE) + return 0; + + if (stk_tlv_append_byte(&builder, response->qualifier) == FALSE) + return 0; + + if (stk_tlv_close_container(&builder) == FALSE) return 0; /* TS 102 223 section 6.8 states: @@ -3081,12 +3096,17 @@ unsigned int stk_pdu_from_response(const struct stk_response *response, * TS 102 384 conformace tests so we set it per command and per * data object type. */ - if ((stk_tlv_open_container(&builder, TRUE, - STK_DATA_OBJECT_TYPE_DEVICE_IDENTITIES, - FALSE) && - stk_tlv_append_byte(&builder, response->src) && - stk_tlv_append_byte(&builder, response->dst) && - stk_tlv_close_container(&builder)) != TRUE) + tag = STK_DATA_OBJECT_TYPE_DEVICE_IDENTITIES; + if (stk_tlv_open_container(&builder, TRUE, tag, FALSE) == FALSE) + return 0; + + if (stk_tlv_append_byte(&builder, response->src) == FALSE) + return 0; + + if (stk_tlv_append_byte(&builder, response->dst) == FALSE) + return 0; + + if (stk_tlv_close_container(&builder) == FALSE) return 0; if (build_dataobj_result(&builder, &response->result, TRUE) != TRUE) |