From 21705f117ad46e8c23d2f24747930bd3b59258bc Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Mon, 30 Jan 2023 14:15:26 +0100 Subject: [PATCH] SonarCloud: Fix redundant parentheses warnings --- api/oc_buffer.c | 2 +- api/oc_session_events.c | 10 +++++----- messaging/coap/observe.c | 6 +++--- security/oc_acl.c | 10 +++++----- security/oc_doxm.c | 3 ++- security/oc_obt.c | 2 +- security/oc_tls.c | 4 ++-- util/oc_process.c | 2 +- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/api/oc_buffer.c b/api/oc_buffer.c index ccfdde4787..aa8aa2df1b 100644 --- a/api/oc_buffer.c +++ b/api/oc_buffer.c @@ -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 */ diff --git a/api/oc_session_events.c b/api/oc_session_events.c index 63172af30e..3035d0e5a6 100644 --- a/api/oc_session_events.c +++ b/api/oc_session_events.c @@ -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); @@ -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; } @@ -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; } @@ -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 */ diff --git a/messaging/coap/observe.c b/messaging/coap/observe.c index f7d18dbf02..e4f8487e3e 100644 --- a/messaging/coap/observe.c +++ b/messaging/coap/observe.c @@ -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 @@ -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) { @@ -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; diff --git a/security/oc_acl.c b/security/oc_acl.c index 50a9755b9b..dbf3c1301e 100644 --- a/security/oc_acl.c +++ b/security/oc_acl.c @@ -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) == diff --git a/security/oc_doxm.c b/security/oc_doxm.c index 25bf71ce5e..3a31a4792e 100644 --- a/security/oc_doxm.c +++ b/security/oc_doxm.c @@ -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); diff --git a/security/oc_obt.c b/security/oc_obt.c index 510ffcf05f..1b603210c0 100644 --- a/security/oc_obt.c +++ b/security/oc_obt.c @@ -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: { diff --git a/security/oc_tls.c b/security/oc_tls.c index 19d629d8cc..238bde95e7 100644 --- a/security/oc_tls.c +++ b/security/oc_tls.c @@ -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 diff --git a/util/oc_process.c b/util/oc_process.c index 93593855f6..ee95b38b5c 100644 --- a/util/oc_process.c +++ b/util/oc_process.c @@ -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");