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

const correctness of oc_rep_get functions #357

Open
Danielius1922 opened this issue Jan 20, 2023 · 1 comment
Open

const correctness of oc_rep_get functions #357

Danielius1922 opened this issue Jan 20, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Danielius1922
Copy link
Member

oc_rep_get functions that const oc_rep_t* and return value stored for given key.

Example:

bool oc_rep_get_string(const oc_rep_t *rep, const char *key, char **value,
                       size_t *size);

The problem is that the value is a pointer to member of the provided const oc_rep_t* and therefore the returned value should also be const.

Functions oc_rep_get_byte_string, oc_rep_get_string, oc_rep_get_int_array, oc_rep_get_bool_array, oc_rep_get_double_array, oc_rep_get_byte_string_array, oc_rep_get_string_array, oc_rep_get_object oc_rep_get_object_array should be modified to return const** value.
(This will however break API so we should issue at least a warning in the changelog).

@Danielius1922 Danielius1922 self-assigned this Jan 20, 2023
@Danielius1922 Danielius1922 added the bug Something isn't working label Jan 20, 2023
@Danielius1922
Copy link
Member Author

Danielius1922 commented Feb 25, 2023

from

typedef void (*oc_obt_discovery_cb_t)(oc_uuid_t *uuid, oc_endpoint_t *eps, void *data);

to

typedef void (*oc_obt_discovery_cb_t)(const oc_uuid_t *uuid, const oc_endpoint_t *eps, void *data);

from

typedef void (*oc_obt_device_status_cb_t)(oc_uuid_t *uuid, int status, void *data);

to

typedef void (*oc_obt_device_status_cb_t)(const oc_uuid_t *uuid, int status, void *data);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant