#define BT_DBG(fmt, arg...) SLOGD(fmt, ##arg)
/* OTP object paths */
-char *otp_obj_path = NULL;
-char *otp_feature_obj_path = NULL;
-char *otp_object_name_obj_path = NULL;
-char *otp_object_type_obj_path = NULL;
-char *otp_object_size_obj_path = NULL;
-char *otp_object_first_created_obj_path = NULL;
-char *otp_object_last_modified_obj_path = NULL;
-char *otp_object_id_obj_path = NULL;
-char *otp_object_prop_obj_path = NULL;
-char *otp_oacp_obj_path = NULL;
-char *otp_olcp_obj_path = NULL;
-char *otp_oacp_desc_obj_path = NULL;
-char *otp_olcp_desc_obj_path = NULL;
+static char *otp_obj_path = NULL;
+static char *otp_feature_obj_path = NULL;
+static char *otp_object_name_obj_path = NULL;
+static char *otp_object_type_obj_path = NULL;
+static char *otp_object_size_obj_path = NULL;
+static char *otp_object_first_created_obj_path = NULL;
+static char *otp_object_last_modified_obj_path = NULL;
+static char *otp_object_id_obj_path = NULL;
+static char *otp_object_prop_obj_path = NULL;
+static char *otp_oacp_obj_path = NULL;
+static char *otp_olcp_obj_path = NULL;
+static char *otp_oacp_desc_obj_path = NULL;
+static char *otp_olcp_desc_obj_path = NULL;
static GMainLoop *main_loop;
-GDBusNodeInfo *otp_node_info = NULL;
+static GDBusNodeInfo *otp_node_info = NULL;
static GDBusConnection *conn;
static GDBusConnection *g_conn;
static int adv_handle = 0;
static gboolean OACP_indicate = FALSE;
static gboolean OLCP_indicate = FALSE;
-char *directory = NULL;
-gboolean mutiple_obj_support = false;
+static char *directory = NULL;
+static gboolean mutiple_obj_support = false;
static gboolean otc_connection_status = FALSE;
-struct oacp_operation *oacp_op = NULL;
-unsigned int timeout_id;
-unsigned int oacp_create_timeout_id;
-uint64_t curr_obj_id, prev_obj_id;
+static struct oacp_operation *oacp_op = NULL;
+static unsigned int timeout_id;
+static unsigned int oacp_create_timeout_id;
+static uint64_t curr_obj_id, prev_obj_id;
static gboolean oacp_create = FALSE;
static const gchar otp_introspection_xml[] =
return TRUE;
}
- BT_DBG("Received data length %d, remote_addr = %s", len, remote_addr);
+ BT_DBG("Received data length %zu, remote_addr = %s", len, remote_addr);
if (!oacp_op->fp) {
char file_path[BT_FILE_PATH_MAX_LEN] = {0, };
if (oacp_op->length_sofar <= oacp_op->length) {
written = fwrite(buffer, 1, len, oacp_op->fp);
oacp_op->length_sofar += written;
- BT_DBG("written [%d], length_sofar [%lu], received_buff_len [%d], size [%lu]",
+ BT_DBG("written [%d], length_sofar [%u], received_buff_len [%zu], size [%u]",
written, oacp_op->length_sofar, len, oacp_op->length);
}
struct stat st;
struct object_metadata *object = NULL;
- g_variant_get(parameters, "(s)", &directory);
+ g_variant_get(parameters, "(&s)", &directory);
BT_DBG("Directory = [%s]", directory);
dir = g_dir_open(directory, 0, &error);
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
int fd;
- g_variant_get(parameters, "(oh)", &dev_path, &index);
+ g_variant_get(parameters, "(&oh)", &dev_path, &index);
msg = g_dbus_method_invocation_get_message(invocation);
fd_list = g_dbus_message_get_unix_fd_list(msg);
_bt_otp_start_write_on_fd();
else if (oacp_op->opcode == OACP_WRITE)
_bt_otp_start_read_on_fd();
+ } else {
+ /* Close fd if oacp_op is NULL */
+ close(fd);
}
g_dbus_method_invocation_return_value(invocation, NULL);
}
curr_obj_index = g_slist_length(otp_object_list) - 1;
curr_obj_id = selected_object->id;
object_id++;
-
- free(uuid);
}
void _bt_otp_restore_old_object()
int opcode = value[0];
uint32_t object_offset, length, object_size;
uint8_t mode = 0;
- char *uuid;
+ char *uuid = NULL;
char absolute_file_path[BT_FILE_PATH_MAX_LEN] = {0, };
BT_INFO("OACP Opcode 0x%d", opcode);
oacp_create = TRUE;
_bt_otp_create_new_object(object_size, uuid);
+ g_free(uuid);
if (oacp_create_timeout_id > 0)
g_source_remove(oacp_create_timeout_id);
if (opcode == OACP_WRITE)
mode = (uint8_t)value[9] & 0xFF;
- BT_INFO("Offset = %lu, Length = %lu", object_offset, length, mode);
+ BT_INFO("Offset = %u, Length = %u", object_offset, length);
if (oacp_op) {
if (otc_connection_status) {
(uint64_t)(value[3] & 0xFF) << 16 |
(uint64_t)(value[2] & 0xFF) << 8 |
(uint64_t)(value[1] & 0xFF);
- BT_INFO("Object ID [%llu]", object_id);
+ BT_INFO("Object ID [%llu]", (unsigned long long int)object_id);
if (selected_object && selected_object->id == object_id)
goto fail;
*len = info->value_length - offset;
*value = (char *)malloc(sizeof(char)*(*len));
+ if (*value == NULL)
+ return BLUETOOTH_ATT_ERROR_INTERNAL;
+
memcpy(*value, info->char_value, *len);
return BLUETOOTH_ATT_ERROR_NONE;
} else {
BT_ERR("Array Len 0");
}
+ g_variant_unref(val);
} else {
BT_ERR("var==NULL");
}
}
}
}
+ g_variant_unref(val);
}
int _bt_otp_init_event_receiver()
NULL, NULL);
device_property_sub_id = g_dbus_connection_signal_subscribe(conn,
- NULL, BT_PROPERTIES_INTERFACE,
+ BT_BLUEZ_NAME, BT_PROPERTIES_INTERFACE,
PROPERTIES_CHANGED, NULL, NULL, 0,
_bt_otp_device_property_event_filter,
NULL, NULL);