added fail case for coap_add_option2
authorJaewook Jung <jw0213.jung@samsung.com>
Fri, 2 Dec 2016 07:07:22 +0000 (16:07 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Wed, 7 Dec 2016 04:40:19 +0000 (04:40 +0000)
commitc580ea569a59a776ae121e4523b0f55bca25fbb2
tree8c69d51549628feab448c9719b67d7bc88b7f9d7
parente589beb7cefc15365f903e98ba0ef16f1cafc4dd
added fail case for coap_add_option2

If coap_add_option2 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_option2 on libcoap-4.1.1
/**
 * Adds option of given type to pdu that is passed as first
 * parameter. coap_add_option2() destroys the PDU's data, so
 * coap_add_data() must be called after all options have been added.
 * As coap_add_token2() destroys the options following the token,
 * the token must be added before coap_add_option2() is called.
 * This function returns the number of bytes written or @c 0 on error.
 */
size_t coap_add_option2(coap_pdu_t *pdu, unsigned short type, unsigned int len,
                        const unsigned char *data, coap_transport_t transport);

Change-Id: I405c77a63902d9c48b50cb9b94448a9f0e1990f0
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15053
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Hyuna Jo <hyuna0213.jo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/caprotocolmessage.c