@@ -436,7 +436,7 @@ static int do_registration_reply_cb(const struct coap_packet *response,
436
436
{
437
437
struct coap_option options [2 ];
438
438
uint8_t code ;
439
- int ret ;
439
+ int ret = - EINVAL ;
440
440
441
441
code = coap_header_get_code (response );
442
442
LOG_DBG ("Registration callback (code:%u.%u)" ,
@@ -448,8 +448,9 @@ static int do_registration_reply_cb(const struct coap_packet *response,
448
448
ret = coap_find_options (response , COAP_OPTION_LOCATION_PATH ,
449
449
options , 2 );
450
450
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 ;
453
454
}
454
455
455
456
/* option[0] should be "rd" */
@@ -459,7 +460,8 @@ static int do_registration_reply_cb(const struct coap_packet *response,
459
460
"%u (expected %zu)\n" ,
460
461
options [1 ].len ,
461
462
sizeof (client .server_ep ));
462
- return - EINVAL ;
463
+ ret = - EINVAL ;
464
+ goto fail ;
463
465
}
464
466
465
467
/* remember the last reg time */
@@ -478,10 +480,10 @@ static int do_registration_reply_cb(const struct coap_packet *response,
478
480
LOG_ERR ("Failed with code %u.%u (%s). Not Retrying." ,
479
481
COAP_RESPONSE_CODE_CLASS (code ), COAP_RESPONSE_CODE_DETAIL (code ),
480
482
code2str (code ));
481
-
483
+ fail :
482
484
sm_handle_failure_state (ENGINE_IDLE );
483
485
484
- return 0 ;
486
+ return ret ;
485
487
}
486
488
487
489
static void do_registration_timeout_cb (struct lwm2m_message * msg )
0 commit comments