net: lwm2m: propagate errors from post_write callbacks

Now that objects and samples have their return values fixed, let's
propagate them back up to the user if there's an error.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
This commit is contained in:
Michael Scott 2017-10-27 15:14:42 -07:00 committed by Jukka Rissanen
commit 353be4cd58

View file

@ -1293,9 +1293,8 @@ static int lwm2m_engine_set(char *pathstr, void *value, u16_t len)
} }
if (res->post_write_cb) { if (res->post_write_cb) {
/* ignore return value here */ ret = res->post_write_cb(obj_inst->obj_inst_id, data_ptr, len,
res->post_write_cb(obj_inst->obj_inst_id, data_ptr, len, false, 0);
false, 0);
} }
if (changed) { if (changed) {
@ -1882,6 +1881,7 @@ static int lwm2m_write_handler_opaque(struct lwm2m_engine_obj_inst *obj_inst,
{ {
size_t len = 1; size_t len = 1;
bool last_pkt_block = false, first_read = true; bool last_pkt_block = false, first_read = true;
int ret = 0;
while (!last_pkt_block && len > 0) { while (!last_pkt_block && len > 0) {
if (first_read) { if (first_read) {
@ -1899,15 +1899,14 @@ static int lwm2m_write_handler_opaque(struct lwm2m_engine_obj_inst *obj_inst,
} }
if (res->post_write_cb) { if (res->post_write_cb) {
/* ignore return value */ ret = res->post_write_cb(obj_inst->obj_inst_id,
res->post_write_cb(obj_inst->obj_inst_id, data_ptr, len,
data_ptr, len, last_pkt_block && last_block,
last_pkt_block && last_block, total_size);
total_size);
} }
} }
return 0; return ret;
} }
/* This function is exposed for the content format writers */ /* This function is exposed for the content format writers */
@ -2055,12 +2054,8 @@ int lwm2m_write_handler(struct lwm2m_engine_obj_inst *obj_inst,
if (res->post_write_cb && if (res->post_write_cb &&
obj_field->data_type != LWM2M_RES_TYPE_OPAQUE) { obj_field->data_type != LWM2M_RES_TYPE_OPAQUE) {
/* ignore return value here */
ret = res->post_write_cb(obj_inst->obj_inst_id, data_ptr, len, ret = res->post_write_cb(obj_inst->obj_inst_id, data_ptr, len,
last_block, total_size); last_block, total_size);
if (ret >= 0) {
ret = 0;
}
} }
NOTIFY_OBSERVER_PATH(path); NOTIFY_OBSERVER_PATH(path);