@@ -436,7 +436,7 @@ static int do_registration_reply_cb(const struct coap_packet *response,
436436{
437437 struct coap_option options [2 ];
438438 uint8_t code ;
439- int ret ;
439+ int ret = - EINVAL ;
440440
441441 code = coap_header_get_code (response );
442442 LOG_DBG ("Registration callback (code:%u.%u)" ,
@@ -448,8 +448,9 @@ static int do_registration_reply_cb(const struct coap_packet *response,
448448 ret = coap_find_options (response , COAP_OPTION_LOCATION_PATH ,
449449 options , 2 );
450450 if (ret < 2 ) {
451- LOG_ERR ("Unexpected endpoint data returned." );
452- return - EINVAL ;
451+ LOG_ERR ("Unexpected endpoint data returned. ret = %d" , ret );
452+ ret = - EINVAL ;
453+ goto fail ;
453454 }
454455
455456 /* option[0] should be "rd" */
@@ -459,7 +460,8 @@ static int do_registration_reply_cb(const struct coap_packet *response,
459460 "%u (expected %zu)\n" ,
460461 options [1 ].len ,
461462 sizeof (client .server_ep ));
462- return - EINVAL ;
463+ ret = - EINVAL ;
464+ goto fail ;
463465 }
464466
465467 /* remember the last reg time */
@@ -478,10 +480,10 @@ static int do_registration_reply_cb(const struct coap_packet *response,
478480 LOG_ERR ("Failed with code %u.%u (%s). Not Retrying." ,
479481 COAP_RESPONSE_CODE_CLASS (code ), COAP_RESPONSE_CODE_DETAIL (code ),
480482 code2str (code ));
481-
483+ fail :
482484 sm_handle_failure_state (ENGINE_IDLE );
483485
484- return 0 ;
486+ return ret ;
485487}
486488
487489static void do_registration_timeout_cb (struct lwm2m_message * msg )
0 commit comments