Skip to content

Commit

Permalink
SonarCloud: Fix redundant parentheses warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 authored and Daniel Adam committed Jan 30, 2023
1 parent fbb13f0 commit 21705f1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion api/oc_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ oc_close_all_tls_sessions_for_device(size_t device)
void
oc_close_all_tls_sessions(void)
{
oc_process_poll(&(oc_tls_handler));
oc_process_poll(&oc_tls_handler);
_oc_signal_event_loop();
}
#endif /* OC_SECURITY */
Expand Down
10 changes: 5 additions & 5 deletions api/oc_session_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ OC_PROCESS_THREAD(oc_session_events, ev, data)
(void)data;
OC_PROCESS_POLLHANDLER(oc_process_session_event());
OC_PROCESS_BEGIN();
while (oc_process_is_running(&(oc_session_events))) {
while (oc_process_is_running(&oc_session_events)) {
OC_PROCESS_YIELD();
}
free_session_state_delayed(NULL);
Expand All @@ -126,7 +126,7 @@ OC_PROCESS_THREAD(oc_session_events, ev, data)
void
oc_session_start_event(const oc_endpoint_t *endpoint)
{
if (!oc_process_is_running(&(oc_session_events))) {
if (!oc_process_is_running(&oc_session_events)) {
return;
}

Expand All @@ -138,14 +138,14 @@ oc_session_start_event(const oc_endpoint_t *endpoint)
oc_list_add(g_session_start_events, ep);
oc_network_event_handler_mutex_unlock();

oc_process_poll(&(oc_session_events));
oc_process_poll(&oc_session_events);
_oc_signal_event_loop();
}

void
oc_session_end_event(const oc_endpoint_t *endpoint)
{
if (!oc_process_is_running(&(oc_session_events))) {
if (!oc_process_is_running(&oc_session_events)) {
return;
}

Expand All @@ -157,7 +157,7 @@ oc_session_end_event(const oc_endpoint_t *endpoint)
oc_list_add(g_session_end_events, ep);
oc_network_event_handler_mutex_unlock();

oc_process_poll(&(oc_session_events));
oc_process_poll(&oc_session_events);
_oc_signal_event_loop();
}
#endif /* OC_TCP */
Expand Down
6 changes: 3 additions & 3 deletions messaging/coap/observe.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ coap_remove_observer(coap_observer_t *o)
const char *query = get_iface_query(o->iface_mask);
oc_blockwise_state_t *response_state = oc_blockwise_find_response_buffer(
oc_string(o->resource->uri) + 1, oc_string_len(o->resource->uri) - 1,
&o->endpoint, OC_GET, query, (query) ? strlen(query) : 0,
&o->endpoint, OC_GET, query, query != NULL ? strlen(query) : 0,
OC_BLOCKWISE_SERVER);
// If response_state->payload_size == 0 it means, that this blockwise state
// doesn't belong to the observer. Because the observer always sets
Expand Down Expand Up @@ -493,7 +493,7 @@ send_notification(coap_observer_t *obs, oc_response_t *response,
oc_blockwise_find_response_buffer(
oc_string(obs->resource->uri) + 1,
oc_string_len(obs->resource->uri) - 1, &obs->endpoint, OC_GET,
query, (query) ? strlen(query) : 0, OC_BLOCKWISE_SERVER);
query, query != NULL ? strlen(query) : 0, OC_BLOCKWISE_SERVER);
if (response_state) {
if (response_state->payload_size ==
response_state->next_block_offset) {
Expand Down Expand Up @@ -1068,7 +1068,7 @@ process_batch_observers(void *data)
const char *query = get_iface_query(obs->iface_mask);
oc_blockwise_state_t *response_state = oc_blockwise_find_response_buffer(
oc_string(obs->resource->uri) + 1, oc_string_len(obs->resource->uri) - 1,
&obs->endpoint, OC_GET, query, (query) ? strlen(query) : 0,
&obs->endpoint, OC_GET, query, query != NULL ? strlen(query) : 0,
OC_BLOCKWISE_SERVER);
if (response_state) {
batch_obs = batch_obs->next;
Expand Down
10 changes: 5 additions & 5 deletions security/oc_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ oc_sec_acl_find_subject(oc_sec_ace_t *start, oc_ace_subject_type_t type,
}
break;
case OC_SUBJECT_ROLE:
if ((oc_string_len(subject->role.role) ==
oc_string_len(ace->subject.role.role) &&
memcmp(oc_string(subject->role.role),
oc_string(ace->subject.role.role),
oc_string_len(subject->role.role)) == 0)) {
if (oc_string_len(subject->role.role) ==
oc_string_len(ace->subject.role.role) &&
memcmp(oc_string(subject->role.role),
oc_string(ace->subject.role.role),
oc_string_len(subject->role.role)) == 0) {
if (oc_string_len(ace->subject.role.authority) == 0) {
return ace;
} else if (oc_string_len(ace->subject.role.authority) ==
Expand Down
3 changes: 2 additions & 1 deletion security/oc_doxm.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@ post_doxm(oc_request_t *request, oc_interface_mask_t iface_mask, void *data)
(void)iface_mask;
(void)data;
oc_tls_peer_t *p = oc_tls_get_peer(request->origin);
if (oc_sec_decode_doxm(request->request_payload, false, (p) ? p->doc : false,
if (oc_sec_decode_doxm(request->request_payload, false,
p != NULL ? p->doc : false,
request->resource->device)) {
oc_send_response(request, OC_STATUS_CHANGED);
oc_sec_dump_doxm(request->resource->device);
Expand Down
2 changes: 1 addition & 1 deletion security/oc_obt.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ get_endpoints(oc_client_response_t *data)
oc_rep_t *links = data->payload;

oc_uuid_t di;
oc_rep_t *link = (links) ? links->value.object : NULL;
oc_rep_t *link = links != NULL ? links->value.object : NULL;
while (link != NULL) {
switch (link->type) {
case OC_REP_STRING: {
Expand Down
4 changes: 2 additions & 2 deletions security/oc_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ oc_tls_audit_log(const char *aeid, const char *message, uint8_t category,
buff[0] = '\0';
}
char *aux[] = { buff };
oc_audit_log((peer) ? peer->endpoint.device : 0, aeid, message, category,
priority, (const char **)aux, 1);
oc_audit_log(peer != NULL ? peer->endpoint.device : 0, aeid, message,
category, priority, (const char **)aux, 1);
}

static int
Expand Down
2 changes: 1 addition & 1 deletion util/oc_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ oc_process_post(struct oc_process *p, oc_process_event_t ev,
if (nevents == OC_PROCESS_NUMEVENTS) {
#ifdef OC_DYNAMIC_ALLOCATION
OC_PROCESS_NUMEVENTS <<= 1;
events = (struct event_data *)realloc(events, (OC_PROCESS_NUMEVENTS) *
events = (struct event_data *)realloc(events, OC_PROCESS_NUMEVENTS *
sizeof(struct event_data));
if (!events) {
oc_abort("Insufficient memory");
Expand Down

0 comments on commit 21705f1

Please sign in to comment.