added fail case for coap_add_option
authorJaewook Jung <jw0213.jung@samsung.com>
Mon, 21 Nov 2016 02:27:38 +0000 (11:27 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 1 Dec 2016 13:24:42 +0000 (13:24 +0000)
commit9de1b757773b06c25282b7a8783d309419f529f5
tree3d80f11999a9f8bd94ddfcf19dbc81e620142538
parent44182110cf55f83da4b2022e58db2f691604e98b
added fail case for coap_add_option

If coap_add_option fails, it has to return fail while sending data.
Otherwise, it causes a crash error when it tries to use a pdu wrong.

The below is the comment for coap_add_option on libcoap-4.1.1

/**
 * Adds option of given type to pdu that is passed as first parameter.
 * coap_add_option() destroys the PDU's data, so coap_add_data() must be called
 * after all options have been added. As coap_add_token() destroys the options
 * following the token, the token must be added before coap_add_option() is
 * called. This function returns the number of bytes written or @c 0 on error.
 */
size_t coap_add_option(coap_pdu_t *pdu,
                       unsigned short type,
                       unsigned int len,
                       const unsigned char *data);

Change-Id: I1add40ab44e0e57e675f56db0211b12414dfa5ae
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14539
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/cablockwisetransfer.c