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

api: add support for creating device after device start up #608

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Danielius1922
Copy link
Member

No description provided.

@ocf-conformance-test-tool
Copy link

🎉 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 (5bf1f87), label this PR with OCF Conformance Testing.

⚠️ Label is removed with every code change.

Copy link

sonarcloud bot commented Feb 10, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

Comment on lines +467 to +476
if (index > device_count) {
OC_ERR("designated device index (%" PRIu32
") is bigger than current number of all devices",
device_count);
return NULL;
}
if (index < device_count) {
OC_ERR("cannot replace existing device (%" PRIu32 ")", device_count);
return NULL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks are weird against then name of oc_core_add_or_update_device_at_index

Is it just allows you append the device?

Comment on lines +372 to +380
size_t device_count = oc_core_get_num_devices();
assert(device_index == device_count - 1);
if (need_realloc) {
oc_swupdate_t *sw =
(oc_swupdate_t *)realloc(g_sw, device_count * sizeof(oc_swupdate_t));
if (sw == NULL) {
oc_abort("Insufficient memory");
}
g_sw = sw;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifdef OC_DYNAMIC_ALLOCATION

@@ -77,6 +77,32 @@ oc_sec_acl_init(void)
}
}

#ifdef OC_HAS_FEATURE_DEVICE_ADD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifdef OC_DYNAMIC_ALLOCATION

@@ -39,6 +39,10 @@
#define OC_HAS_FEATURE_PUSH
#endif

#if defined(OC_SERVER) && defined(OC_CLIENT) && defined(OC_DYNAMIC_ALLOCATION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it his required to have OC_DYNAMIC_ALLOCATION ?

Comment on lines +69 to +81
if (needs_realloc) {
size_t device_count = oc_core_get_num_devices();
assert(device_index == device_count - 1);
oc_sec_sdi_t *sdi =
(oc_sec_sdi_t *)realloc(g_sdi, device_count * sizeof(oc_sec_sdi_t));
if (sdi == NULL) {
oc_abort("Insufficient memory");
}
g_sdi = sdi;
} else {
sec_sdi_free(&g_sdi[device_index]);
}
#endif /* OC_DYNAMIC_ALLOCATION */
memset(&g_sdi[device_index], 0, sizeof(oc_sec_sdi_t));
Copy link
Member

@jkralik jkralik Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw same pattern at lot's places -> is it possible to move it to generic function ?

void
oc_instantiate_object_at_index(void** array, item_size size_t, index size_t, bool needs_realloc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants