Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverity issues (5) #482

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
-DOC_WKCORE_ENABLED=ON
-DOC_SOFTWARE_UPDATE_ENABLED=ON
-DOC_PUSH_ENABLED=ON
-DOC_DISCOVERY_RESOURCE_OBSERVABLE_ENABLED=ON
-DOC_RESOURCE_ACCESS_IN_RFOTM_ENABLED=ON
-DPLGD_DEV_TIME_ENABLED=ON
-B ${{github.workspace}}/build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-cloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
matrix:
include:
# cloud (ipv4+tcp) on, collection create on, push on, rfotm on
- build_args: "-DOC_CLOUD_ENABLED=ON -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_PUSH_ENABLED=ON -DOC_RESOURCE_ACCESS_IN_RFOTM_ENABLED=ON"
- build_args: "-DOC_CLOUD_ENABLED=ON -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_PUSH_ENABLED=ON -DOC_DISCOVERY_RESOURCE_OBSERVABLE_ENABLED=ON -DOC_RESOURCE_ACCESS_IN_RFOTM_ENABLED=ON"
# ipv6 dns on, oscore off, rep realloc on
- build_args: "-DOC_DNS_LOOKUP_IPV6_ENABLED=ON -DOC_OSCORE_ENABLED=OFF -DOC_REP_ENCODING_REALLOC=ON"
# ipv4 on, tcp on, dynamic allocation off, rfotm on
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ if(BUILD_TESTING AND(UNIX OR MINGW))
oc_package_add_test(TARGET platformtest SOURCES ${COMMONTEST_SRC} ${PLATFORMTEST_SRC})

file(GLOB MESSAGINGTEST_SRC messaging/coap/unittest/*.cpp)
oc_package_add_test(TARGET messagingtest SOURCES ${MESSAGINGTEST_SRC})
oc_package_add_test(TARGET messagingtest SOURCES ${COMMONTEST_SRC} ${MESSAGINGTEST_SRC})

if(OC_SECURITY_ENABLED)
file(GLOB SECURITYTEST_SRC security/unittest/*.cpp)
Expand Down
4 changes: 2 additions & 2 deletions api/oc_ri.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ oc_ri_delete_resource(oc_resource_t *resource)
#endif /* (OC_COLLECTIONS) */

if (resource->num_observers > 0) {
int removed_num = coap_remove_observer_by_resource(resource);
int removed_num = coap_remove_observers_by_resource(resource);
OC_DBG("removing resource observers: removed(%d) vs expected(%d)",
removed_num, resource->num_observers);
#if !OC_DBG_IS_ENABLED
Expand Down Expand Up @@ -1087,7 +1087,7 @@ oc_observe_notification_resource_defaults_delayed(void *data)
oc_resource_defaults_data_t *resource_defaults_data =
(oc_resource_defaults_data_t *)data;
notify_resource_defaults_observer(resource_defaults_data->resource,
resource_defaults_data->iface_mask, NULL);
resource_defaults_data->iface_mask);
oc_ri_dealloc_resource_defaults(resource_defaults_data);
return OC_EVENT_DONE;
}
Expand Down
5 changes: 3 additions & 2 deletions api/oc_server_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,14 +843,15 @@ oc_notify_observers_delayed_ticks(oc_resource_t *resource,
void
oc_notify_observers_delayed(oc_resource_t *resource, uint16_t seconds)
{
oc_clock_time_t ticks = seconds * OC_CLOCK_SECOND;
oc_clock_time_t ticks = (oc_clock_time_t)seconds * OC_CLOCK_SECOND;
oc_notify_observers_delayed_ticks(resource, ticks);
}

void
oc_notify_observers_delayed_ms(oc_resource_t *resource, uint16_t milliseconds)
{
oc_clock_time_t ticks = milliseconds * OC_CLOCK_SECOND / 1000;
oc_clock_time_t ticks =
(oc_clock_time_t)milliseconds * OC_CLOCK_SECOND / 1000;
oc_notify_observers_delayed_ticks(resource, ticks);
}

Expand Down
2 changes: 1 addition & 1 deletion api/oc_session_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ handle_session_disconnected(const oc_endpoint_t *endpoint)
#endif /* OC_SECURITY */
#ifdef OC_SERVER
/* remove all observations for the endpoint */
coap_remove_observer_by_client(endpoint);
coap_remove_observers_by_client(endpoint);
#endif /* OC_SERVER */
}

Expand Down
1 change: 1 addition & 0 deletions api/unittest/plgdtimetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ TEST_F(TestPlgdTime, Seconds)
oc_clock_time_t start_ts = start / OC_CLOCK_SECOND;
EXPECT_LE(start_ts, now_ts);
EXPECT_GT(oc_clock_seconds(), now_ts);
EXPECT_GT(oc_clock_seconds_v1(), now_ts);
}

TEST_F(TestPlgdTime, IsActive)
Expand Down
Loading