Skip to content

Commit 685e08d

Browse files
author
Tero Heinonen
committed
Warnings cleaned.
1 parent 6c6e672 commit 685e08d

File tree

5 files changed

+13
-22
lines changed

5 files changed

+13
-22
lines changed

coap-service/coap_service_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ extern int8_t coap_service_unregister_uri(int8_t service_id, const char *uri);
228228
*
229229
* \return msg_id Id number of the current message.
230230
*/
231-
extern uint16_t coap_service_request_send(int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16], uint16_t destination_port, uint8_t msg_type, uint8_t msg_code, const char *uri,
231+
extern uint16_t coap_service_request_send(int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16], uint16_t destination_port, sn_coap_msg_type_e msg_type, sn_coap_msg_code_e msg_code, const char *uri,
232232
uint8_t cont_type, const uint8_t *payload_ptr, uint16_t payload_len, coap_service_response_recv *request_response_cb);
233233

234234
/**

source/coap_message_handler.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ static void own_free(void *ptr)
3131

3232
static NS_LIST_DEFINE(request_list, coap_transaction_t, link);
3333

34-
static coap_transaction_t *transaction_find_client(uint16_t msg_id)
35-
{
36-
coap_transaction_t *this = NULL;
37-
ns_list_foreach(coap_transaction_t, cur_ptr, &request_list) {
38-
if (cur_ptr->msg_id == msg_id && cur_ptr->client_request) {
39-
this = cur_ptr;
40-
break;
41-
}
42-
}
43-
return this;
44-
}
45-
4634
static coap_transaction_t *transaction_find_client_by_token(uint8_t token[4])
4735
{
4836
coap_transaction_t *this = NULL;
@@ -246,7 +234,7 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
246234
}
247235

248236
uint16_t coap_message_handler_request_send(coap_msg_handler_t *handle, int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16],
249-
uint16_t destination_port, uint8_t msg_type, uint8_t msg_code, const char *uri,
237+
uint16_t destination_port, sn_coap_msg_type_e msg_type, sn_coap_msg_code_e msg_code, const char *uri,
250238
uint8_t cont_type, const uint8_t *payload_ptr, uint16_t payload_len, coap_message_handler_response_recv *request_response_cb)
251239
{
252240
coap_transaction_t *transaction_ptr;
@@ -279,7 +267,7 @@ uint16_t coap_message_handler_request_send(coap_msg_handler_t *handle, int8_t se
279267
request.msg_code = msg_code;
280268
request.uri_path_ptr = (uint8_t *)uri;
281269
request.uri_path_len = strlen(uri);
282-
coap_service_build_content_format(&request, cont_type);
270+
coap_service_build_content_format(&request, (sn_coap_content_format_e)cont_type);
283271

284272
do{
285273
randLIB_get_n_bytes_random(token,4);
@@ -344,7 +332,7 @@ int8_t coap_message_handler_response_send(coap_msg_handler_t *handle, int8_t ser
344332
}
345333
response->payload_len = payload_len;
346334
response->payload_ptr = (uint8_t *) payload_ptr; // Cast away const and trust that nsdl doesn't modify...
347-
coap_service_build_content_format(response, content_type);
335+
coap_service_build_content_format(response, (sn_coap_content_format_e)content_type);
348336

349337
data_len = sn_coap_builder_calc_needed_packet_data_size(response);
350338
data_ptr = own_alloc(data_len);

source/coap_security_handler.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,13 @@ int thread_security_send_close_alert(coap_security_t *sec)
352352
if( !sec ){
353353
return -1;
354354
}
355-
return mbedtls_ssl_close_notify(&sec->_ssl);
356355

357-
coap_security_handler_reset(sec);
358-
coap_security_handler_init(sec);
356+
if(!mbedtls_ssl_close_notify(&sec->_ssl)){
357+
coap_security_handler_reset(sec);
358+
coap_security_handler_init(sec);
359+
return 0;
360+
}
361+
return -1;
359362
}
360363

361364
int coap_security_handler_read(coap_security_t *sec, unsigned char* buffer, size_t len){
@@ -392,7 +395,7 @@ int entropy_poll( void *ctx, unsigned char *output, size_t len,
392395
}
393396
memset(c, 0, len);
394397
for(uint16_t i=0; i < len; i++){
395-
c[i] = (char)randLIB_get_8bit;
398+
*(c + 1) = (char)randLIB_get_8bit();
396399
}
397400
memmove(output, c, len);
398401
*olen = len;

source/coap_service_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ int8_t coap_service_unregister_uri(int8_t service_id, const char *uri)
437437
return 0;
438438
}
439439

440-
uint16_t coap_service_request_send(int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16], uint16_t destination_port, uint8_t msg_type, uint8_t msg_code, const char *uri,
440+
uint16_t coap_service_request_send(int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16], uint16_t destination_port, sn_coap_msg_type_e msg_type, sn_coap_msg_code_e msg_code, const char *uri,
441441
uint8_t cont_type, const uint8_t *payload_ptr, uint16_t payload_len, coap_service_response_recv *request_response_cb){
442442
//TODO: coap_service_response_recv is an ugly cast, this should be refactored away + sn_coap_hdr_s MUST NOT be exposed to users of coap-service!
443443
//Callback would be still needed, but where to store callback?

source/include/coap_message_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle,
5757
uint8_t *data_ptr, uint16_t data_len, int16_t (cb)(int8_t, sn_coap_hdr_s *, coap_transaction_t *));
5858

5959
extern uint16_t coap_message_handler_request_send(coap_msg_handler_t *handle, int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16],
60-
uint16_t destination_port, uint8_t msg_type, uint8_t msg_code, const char *uri, uint8_t cont_type,
60+
uint16_t destination_port, sn_coap_msg_type_e msg_type, sn_coap_msg_code_e msg_code, const char *uri, uint8_t cont_type,
6161
const uint8_t *payload_ptr, uint16_t payload_len, coap_message_handler_response_recv *request_response_cb);
6262

6363
extern int8_t coap_message_handler_response_send(coap_msg_handler_t *handle, int8_t service_id, uint8_t options, sn_coap_hdr_s *request_ptr, sn_coap_msg_code_e message_code,

0 commit comments

Comments
 (0)