-
Notifications
You must be signed in to change notification settings - Fork 66
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
OCF Bridging #588
OCF Bridging #588
Conversation
- bugfix: oc_ri_delete_app_resources_per_device() => fix infinite loop - remove function: oc_resource_set_data_remover() => not necessary any more
…e = false oc_virtual_device_t : remove ecosystem_device field
merge bridging feature
Merge bridging
🎉 Thank you for your code contribution! To guarantee the change/addition is conformant to the OCF Specification, we would like to ask you to execute OCF Conformance Testing of your change ☝️ when your work is ready to be reviewed. ℹ️ To verify your latest change (bcb3671), label this PR with |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
@joochlee please check https://github.com/iotivity/iotivity-lite/actions/runs/7492383923/job/20395748989 , https://github.com/iotivity/iotivity-lite/actions/runs/7492383941/job/20395750617 and https://github.com/iotivity/iotivity-lite/actions/runs/7492383941/job/20395751298 there some documentation and printf formats compile errors |
PR #592 replaces this one |
I don't understand why code coverage of sonarcloud is so low.. |
Yes, please try to fix the issues, we need SC to pass before we can merge. These are core files, so these need to be tested. Ignore those type mismatch warnings, those are won't fix, I'll click those in the SC GUI (there is also usually other type of warning about that the programmer should use a concrete type instead of void*, those should be ignored as well). For coverage, well new code needs new unit tests, no? Usually a .c file has a .cpp unittest file that tests it. So, for example you've added |
do we need unittest for functions defined in "oc_*_internal.h" ? |
Well, it depends. Priority is to have public functions tested, so if the tests of a public function also test some internal function then it's not necessary to add separate tests for the internal function. However, sometimes it is easier to add unit tests for an internal function than setting up the tests of a parent function to hit the internal function. |
Hi, Is there any way to run specific test case ? |
Not sure if it is possible using ctest, but I do it by running the test binary with the For example, if you want to run
|
Thank you ! |
Another question. |
The use is inconsistent in the repo, but I use it like this: "_P" (positive/passing path, meaning that the tested function succeeds) and "_F" (failure path, the tested function fails) |
got it, Thanks ! |
630b2de
to
4d54fc0
Compare
…s, fix sonarCloud codesmells/security hot spots
@@ -609,6 +630,12 @@ oc_get_next_collection_with_link(const oc_resource_t *resource, | |||
collection = (oc_collection_t *)collection->res.next; | |||
} | |||
|
|||
/* | |||
* FIXED <2024/01/23> oc_get_next_collection_with_link() : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, seems like a bug. The original version seems to pressupose that the list of collections is ordered by device index, but this is not ensured by oc_collection_add
when a new collection is added to the list.
Remove the old version and keep the fixed code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
#include "security/oc_ael_internal.h" | ||
#include "oc_acl.h" | ||
#include "oc_cred.h" | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef OC_HAS_FEATURE_BRIDGE
#include "oc_acl.h"
#include "oc_cred.h"
#ifdef OC_SECURITY
#include "security/oc_ael_internal.h"
#include "security/oc_svr_internal.h"
#endif /* OC_SECURITY*/
#endif /* OC_HAS_FEATURE_BRIDGE */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it's much better!
@@ -2300,7 +2301,9 @@ oc_push_free(void) | |||
_purge_recv_obj_list(recvs_instance); | |||
OC_PUSH_DBG("free push receiver Resource (device: %zu)... ", | |||
recvs_instance->resource->device); | |||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the recvs_instance->resource
leaking now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not.
recvs_instance->resource
points Push Receiver Resource (oic.r.pushreceiver
) which is one of App Resources.
All App Resources are removed by oc_ri_shutdown()
as you know.
so I think that letting oc_ri_shutdown()
do its own job is better idea.
what do you think ?
@@ -105,6 +112,7 @@ oc_core_init(void) | |||
#endif /* OC_DYNAMIC_ALLOCATION */ | |||
} | |||
|
|||
#ifdef OC_DYNAMIC_ALLOCATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a leak
, oc_free_string
has to be called even when dynamic allocation is disabled, because oc_strings use a shared byte pool buffer and without this deallocation
the buffers aren't returned to the shared pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oc_core_free_device_info_properties()
are called by 2 functions : oc_core_shutdown()
and oc_core_remove_device_at_index()
.
When OC_DYNAMIC_ALLOCATION = OFF
, oc_core_remove_device_at_index()
and code block calling
oc_core_remove_device_at_index()
of oc_core_shutdown()
are disabled.
Therefore, If I remove #ifdef OC_DYNAMIC_ALLOCATION
directive, oc_core_free_device_info_properties()
is used by none. so gcc complains that this function is never used...
bool | ||
oc_core_remove_device_at_index(size_t index) | ||
{ | ||
if (index >= g_device_count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace with oc_core_device_is_valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
#ifdef OC_SECURITY | ||
oc_reset_device(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases schedules delayed events - I see cloud deregistration and closing of TLS sessions for the device. We might be in for a nasty surprise when those events execute with a deleted device.
res = res->next; | ||
} | ||
|
||
oc_collections_free_per_device(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef OC_COLLECTIONS
oc_collections_free_per_device(index);
#endif /* OC_COLLECTIONS */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* @return non-NULL found resource | ||
* @return NULL no more resource or end of list | ||
*/ | ||
oc_resource_t *oc_ri_get_app_resource_by_device(size_t device, bool reset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do oc_ri_get_app_resource_by_device
and oc_ri_delete_app_resources_per_device
need to be part of the public API? I don't see them used in any apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oc_ri_get_app_resource_by_device()
is used by bridge_manager
module (not uploaded yet)
oc_ri_delete_app_resources_per_device()
is used by oc_core_remove_device_at_index()
in oc_core_res.c
.
oc_resource_t * | ||
oc_ri_get_app_resource_by_device(size_t device, bool reset) | ||
{ | ||
static oc_resource_t *rsc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd copy the semantics of g_query_iterator
, so that we are consistent.
typedef struct {
oc_resource_t *rsc;
#ifdef OC_COLLECTIONS
oc_resource_t *coll_rsc;
#endif
} oc_ri_app_resource_iterator_t;
static oc_ri_app_resource_iterator_t g_app_resource_iterator;
void oc_ri_app_resource_iterator_init() {
g_app_resource_iterator.rsc = oc_ri_get_app_resources();
#ifdef OC_COLLECTIONS
g_app_resource_iterator.coll_rsc = oc_collection_get_collections();
#endif
}
oc_resource_t* oc_ri_app_resource_iterator_next_for_device(size_t device) {
...
}
We also need to mention that deleting / adding a resource (collection or non-collection) invalidates the iterator.
|
||
#ifdef OC_HAS_FEATURE_BRIDGE | ||
oc_string_t | ||
ecoversion; ///< Version of ecosystem that a Bridged Device belongs to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove. I don't see this used anywhere in this PR, add it when its functionality is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Renamed the feature branch to feature/ocfbridging , lets continue there and hopefully will bring the feature to master once all issues are solved. |
No description provided.