Skip to content

Commit

Permalink
Fix issues reported by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Jun 22, 2023
1 parent 4eb6a97 commit f91994b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
36 changes: 19 additions & 17 deletions api/oc_ri.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,29 +1388,31 @@ oc_ri_invoke_coap_entity_handler(const coap_packet_t *request,
bool response_state_allocated = false;
bool enable_realloc_rep = false;
#endif /* OC_DYNAMIC_ALLOCATION */
if (cur_resource && !bad_request && *ctx.response_state == NULL) {
OC_DBG("creating new block-wise response state");
*ctx.response_state = oc_blockwise_alloc_response_buffer(
uri_path, uri_path_len, endpoint, method, OC_BLOCKWISE_SERVER,
OC_MIN_APP_DATA_SIZE);
if (cur_resource && !bad_request) {
if (*ctx.response_state == NULL) {
OC_ERR("failure to alloc response state");
bad_request = true;
} else {
OC_DBG("creating new block-wise response state");
*ctx.response_state = oc_blockwise_alloc_response_buffer(
uri_path, uri_path_len, endpoint, method, OC_BLOCKWISE_SERVER,
OC_MIN_APP_DATA_SIZE);
if (*ctx.response_state == NULL) {
OC_ERR("failure to alloc response state");
bad_request = true;
} else {
#ifdef OC_DYNAMIC_ALLOCATION
#ifdef OC_APP_DATA_BUFFER_POOL
if (!request_buffer->block)
if (!request_buffer->block)
#endif /* OC_APP_DATA_BUFFER_POOL */
{
response_state_allocated = true;
}
{
response_state_allocated = true;
}
#endif /* OC_DYNAMIC_ALLOCATION */
if (uri_query_len > 0) {
oc_new_string(&(*ctx.response_state)->uri_query, uri_query,
uri_query_len);
if (uri_query_len > 0) {
oc_new_string(&(*ctx.response_state)->uri_query, uri_query,
uri_query_len);
}
response_buffer.buffer = (*ctx.response_state)->buffer;
response_buffer.buffer_size = OC_MIN_APP_DATA_SIZE;
}
response_buffer.buffer = (*ctx.response_state)->buffer;
response_buffer.buffer_size = OC_MIN_APP_DATA_SIZE;
}
}
#else /* OC_BLOCK_WISE */
Expand Down
6 changes: 3 additions & 3 deletions security/oc_obt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3567,15 +3567,15 @@ oc_obt_general_post(const oc_uuid_t *uuid, const char *query, const char *url,
oc_rep_start_root_object();
for (int i = 0; i < array_size; i++) {
if (strstr(payload_types[i], "bool") != NULL) {
int payload_int = strtol(payload_values[i], NULL, 10);
bool payload_bool = (payload_int ? true : false);
long payload_int = strtol(payload_values[i], NULL, 10);
bool payload_bool = (payload_int != 0 ? true : false);

oc_rep_encode_text_string(&root_map, payload_properties[i],
strlen(payload_properties[i]));
oc_rep_encode_boolean(&root_map, payload_bool);

} else if (strstr(payload_types[i], "int") != NULL) {
int payload_int = strtol(payload_values[i], NULL, 10);
long payload_int = strtol(payload_values[i], NULL, 10);

oc_rep_encode_text_string(&root_map, payload_properties[i],
strlen(payload_properties[i]));
Expand Down

0 comments on commit f91994b

Please sign in to comment.