iotivity-lite icon indicating copy to clipboard operation
iotivity-lite copied to clipboard

const correctness of oc_rep_get functions

Open Danielius1922 opened this issue 2 years ago • 1 comments

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 avatar Jan 20 '23 13:01 Danielius1922

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);

Danielius1922 avatar Feb 25 '23 20:02 Danielius1922