static const char* SVR_DB_FILE_NAME = "oic_svr_db_subowner_client.dat";
static const char* PRVN_DB_FILE_NAME = "oic_pdm_subowner.db";
+#ifdef TEST
static const OicSecPrm_t SUPPORTED_PRMS[2] = { PRM_PRE_CONFIGURED, PRM_RANDOM_PIN };
+#endif
typedef struct {
d2ds_cmd_id_e cid; /**< Command ID */
(*uuid).id[12], (*uuid).id[13], (*uuid).id[14], (*uuid).id[15]);
D2DS_LOGI("%s", uuid_string);
}
+
+#ifdef TEST
static OCProvisionDev_t* _get_dev_by_id(const OCProvisionDev_t* dev_lst, const int dev_num)
{
if(!dev_lst || 0>=dev_num) {
return NULL;
}
+#endif
static OCProvisionDev_t* _get_dev_by_uuid(const OCProvisionDev_t* dev_lst,
const OicUuid_t* uuid)
SetInputPinCB(_input_pin_cb);
- g_client = calloc(1, sizeof(d2ds_subowner_s));
+ g_client = g_malloc0(sizeof(d2ds_subowner_s));
if(!g_client) {
D2DS_LOGE( "memory allocation error = %d", errno);
return D2DS_ERROR_OUT_OF_MEMORY;
}
con->sid = 0;
con->found = FALSE;
-#if 0
- if (con->target) {
- PMDeleteDeviceList(con->target);
- con->target = NULL;
- }
-#endif
+
if (con->pin) {
free(con->pin);
con->pin = NULL;
}
-#if 0
- D2DS_LOGE("KSR : %p", con->subject);
- if (con->subject) {
- PMDeleteDeviceList(con->subject);
- con->subject = NULL;
- }
-#endif
if (con->rsrc_uri) {
free(con->rsrc_uri);
con->rsrc_uri = NULL;
}
}
+#ifdef TEST
static gboolean _d2ds_timeout_cb(gpointer data)
{
d2ds_req_cb_s *con = (d2ds_req_cb_s *)data;
return G_SOURCE_REMOVE;
}
+#endif
static gpointer _disc_mot_env_devs_func(gpointer data)
{
static int _disc_mot_enb_devs(d2ds_service *service)
{
d2ds_req_cb_s *con = NULL;
- con = calloc(1, sizeof(d2ds_req_cb_s));
+ con = g_malloc0(sizeof(d2ds_req_cb_s));
if (NULL == con) {
- D2DS_LOGE( "calloc() Fail=%d", errno);
+ D2DS_LOGE( "g_malloc0() Fail=%d", errno);
return D2DS_ERROR_OUT_OF_MEMORY;
}
g_client->g_mowndev_cnt = _print_dev_list(g_client->g_mowned_list);
DISC_OWNED_DEVS_END:
- _request_cleanup(data);
+ _request_cleanup(con);
g_thread_exit(GINT_TO_POINTER (1));
return NULL;
static int _disc_owned_devs(d2ds_service *service)
{
d2ds_req_cb_s *con = NULL;
- con = calloc(1, sizeof(d2ds_req_cb_s));
+ con = g_malloc0(sizeof(d2ds_req_cb_s));
if (NULL == con) {
- D2DS_LOGE( "calloc() Fail=%d", errno);
+ D2DS_LOGE( "g_malloc0() Fail=%d", errno);
return D2DS_ERROR_OUT_OF_MEMORY;
}
if (NULL == device_id)
return NULL;
- uuid = calloc(1, sizeof(struct OicUuid));
+ uuid = g_malloc0(sizeof(struct OicUuid));
if (NULL == uuid) {
- D2DS_LOGE("calloc() Fail(%d)", errno);
+ D2DS_LOGE("g_malloc0() Fail(%d)", errno);
return NULL;
}
OCProvisionDev_t *src_dev = NULL;
d2ds_req_cb_s *con = NULL;
- con = calloc(1, sizeof(d2ds_req_cb_s));
+ con = g_malloc0(sizeof(d2ds_req_cb_s));
if (NULL == con) {
- D2DS_LOGE( "calloc() Fail=%d", errno);
+ D2DS_LOGE( "g_malloc0() Fail=%d", errno);
/* Unset d2ds status 'pending' */
g_atomic_int_set(&service->pending, 0);
return D2DS_ERROR_OUT_OF_MEMORY;
con->target->next = NULL;
if (pin) {
- con->pin = calloc(1, OXM_RANDOM_PIN_MAX_SIZE+1);
+ con->pin = g_malloc0(OXM_RANDOM_PIN_MAX_SIZE+1);
if (!pin) {
D2DS_LOGE("Failed to allocate PIN number");
_request_cleanup(con);
OCProvisionDev_t *subject_dev = NULL;
d2ds_req_cb_s *con = NULL;
- con = calloc(1, sizeof(d2ds_req_cb_s));
+ con = g_malloc0(sizeof(d2ds_req_cb_s));
if (NULL == con) {
- D2DS_LOGE( "calloc() Fail=%d", errno);
+ D2DS_LOGE( "g_malloc0() Fail=%d", errno);
/* Unset d2ds status 'pending' */
g_atomic_int_set(&service->pending, 0);
return D2DS_ERROR_OUT_OF_MEMORY;
return NULL;
}
-static int _d2ds_provisioning_cred(d2ds_service *service,
+static int _provisioning_cred(d2ds_service *service,
gchar *uuid_dev1, gchar *uuid_dev2)
{
OCProvisionDev_t *dev2 = NULL;
d2ds_req_cb_s *con = NULL;
- con = calloc(1, sizeof(d2ds_req_cb_s));
+ con = g_malloc0(sizeof(d2ds_req_cb_s));
if (!con) {
- D2DS_LOGE( "calloc() Fail=%d", errno);
+ D2DS_LOGE( "g_malloc0() Fail=%d", errno);
/* Unset d2ds status 'pending' */
g_atomic_int_set(&service->pending, 0);
return D2DS_ERROR_OUT_OF_MEMORY;
/* Set d2ds status 'pending' */
g_atomic_int_set(&service->pending, 1);
- ret = _d2ds_provisioning_cred(service, uuid_dev1, uuid_dev2);
+ ret = _provisioning_cred(service, uuid_dev1, uuid_dev2);
return ret;
}