Some coding style fixes and removed unused function.

This commit is contained in:
Claudio Takahasi 2009-10-22 15:39:26 -02:00
parent ece9ea1c2e
commit 8300366080
3 changed files with 62 additions and 73 deletions

View File

@ -131,12 +131,6 @@ static struct voice_call *find_vc_with_status(int status)
return NULL;
}
static inline DBusMessage *invalid_args(DBusMessage *msg)
{
return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
"Invalid arguments in method call");
}
void telephony_device_connected(void *telephony_device)
{
debug("telephony-ofono: device %p connected", telephony_device);
@ -277,18 +271,19 @@ void telephony_answer_call_req(void *telephony_device)
void telephony_dial_number_req(void *telephony_device, const char *number)
{
char *clir = "default";
const char *clir;
int ret;
debug("telephony-ofono: dial request to %s", number);
if (!strncmp(number, "*31#", 4)) {
number += 4;
clir = g_strdup("enabled");
clir = "enabled";
} else if (!strncmp(number, "#31#", 4)) {
number += 4;
clir = g_strdup("disabled");
}
clir = "disabled";
} else
clir = "default";
ret = send_method_call(OFONO_BUS_NAME, modem_obj_path,
OFONO_VCMANAGER_INTERFACE,
@ -417,7 +412,7 @@ static gboolean iter_get_basic_args(DBusMessageIter *iter,
static void handle_registration_property(const char *property, DBusMessageIter sub)
{
char *status, *operator;
const char *status, *operator;
unsigned int signals_bar;
if (g_str_equal(property, "Status")) {
@ -627,7 +622,7 @@ static void vc_getproperties_reply(DBusPendingCall *call, void *user_data)
err.name, err.message);
dbus_error_free(&err);
goto done;
}
}
vc = find_vc(path);
if (!vc) {
@ -640,28 +635,28 @@ static void vc_getproperties_reply(DBusPendingCall *call, void *user_data)
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
error("Unexpected signature in vc_getproperties_reply()");
goto done;
}
}
dbus_message_iter_recurse(&iter, &iter_entry);
if (dbus_message_iter_get_arg_type(&iter_entry)
!= DBUS_TYPE_DICT_ENTRY) {
!= DBUS_TYPE_DICT_ENTRY) {
error("Unexpected signature in vc_getproperties_reply()");
goto done;
}
}
while (dbus_message_iter_get_arg_type(&iter_entry)
!= DBUS_TYPE_INVALID) {
!= DBUS_TYPE_INVALID) {
DBusMessageIter iter_property, sub;
char *property, *cli, *state;
dbus_message_iter_recurse(&iter_entry, &iter_property);
if (dbus_message_iter_get_arg_type(&iter_property)
!= DBUS_TYPE_STRING) {
!= DBUS_TYPE_STRING) {
error("Unexpected signature in"
" vc_getproperties_reply()");
goto done;
}
}
dbus_message_iter_get_basic(&iter_property, &property);
@ -729,7 +724,7 @@ static void handle_vcmanager_property_changed(DBusMessage *msg,
{
DBusMessageIter iter, sub, array;
const char *property, *vc_obj_path = NULL;
struct voice_call *vc = NULL, *vc_new = NULL;
struct voice_call *vc, *vc_new = NULL;
debug("in handle_vcmanager_property_changed");
@ -790,7 +785,7 @@ static void handle_vc_property_changed(DBusMessage *msg, const char *obj_path)
{
DBusMessageIter iter, sub;
const char *property, *state;
struct voice_call *vc = NULL;
struct voice_call *vc;
debug("in handle_vc_property_changed, obj_path is %s", obj_path);

View File

@ -26,13 +26,8 @@
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
@ -43,15 +38,12 @@
#include <glib.h>
#include <dbus/dbus.h>
#include "hcid.h"
#include "sdpd.h"
#include "adapter.h"
#include "plugin.h"
#include "logging.h"
#include "manager.h"
#include "storage.h"
static int child_pipe[2] = { -1, -1 };
@ -88,7 +80,7 @@ static void configure_device(int index)
{
struct hci_dev_info di;
uint16_t policy;
int dd;
int dd, err;
if (hci_devinfo(index, &di) < 0)
return;
@ -98,8 +90,9 @@ static void configure_device(int index)
dd = hci_open_dev(index);
if (dd < 0) {
err = errno;
error("Can't open device hci%d: %s (%d)",
index, strerror(errno), errno);
index, strerror(err), err);
return;
}
@ -125,7 +118,7 @@ static void init_device(int index)
struct hci_dev_req dr;
struct hci_dev_info di;
pid_t pid;
int dd;
int dd, err;
/* Do initialization in the separate process */
pid = fork();
@ -134,8 +127,9 @@ static void init_device(int index)
atexit(at_child_exit);
break;
case -1:
err = errno;
error("Fork failed. Can't init device hci%d: %s (%d)",
index, strerror(errno), errno);
index, strerror(err), err);
default:
debug("child %d forked", pid);
return;
@ -143,8 +137,9 @@ static void init_device(int index)
dd = hci_open_dev(index);
if (dd < 0) {
err = errno;
error("Can't open device hci%d: %s (%d)",
index, strerror(errno), errno);
index, strerror(err), err);
exit(1);
}
@ -154,8 +149,9 @@ static void init_device(int index)
/* Set link mode */
dr.dev_opt = main_opts.link_mode;
if (ioctl(dd, HCISETLINKMODE, (unsigned long) &dr) < 0) {
err = errno;
error("Can't set link mode on hci%d: %s (%d)",
index, strerror(errno), errno);
index, strerror(err), err);
}
/* Set link policy */
@ -251,29 +247,27 @@ static int init_known_adapters(int ctl)
dl = g_try_malloc0(HCI_MAX_DEV * sizeof(struct hci_dev_req) + sizeof(uint16_t));
if (!dl) {
err = -errno;
err = errno;
error("Can't allocate devlist buffer: %s (%d)",
strerror(errno), errno);
return err;
strerror(err), err);
return -err;
}
dl->dev_num = HCI_MAX_DEV;
dr = dl->dev_req;
if (ioctl(ctl, HCIGETDEVLIST, (void *) dl) < 0) {
err = -errno;
err = errno;
error("Can't get device list: %s (%d)",
strerror(errno), errno);
return err;
strerror(err), err);
g_free(dl);
return -err;
}
for (i = 0; i < dl->dev_num; i++, dr++) {
gboolean devup;
device_event(HCI_DEV_REG, dr->dev_id);
devup = hci_test_bit(HCI_UP, &dr->dev_opt);
if (devup)
if (hci_test_bit(HCI_UP, &dr->dev_opt))
device_event(HCI_DEV_UP, dr->dev_id);
}
@ -337,9 +331,9 @@ static int hciops_setup(void)
return -EALREADY;
if (pipe(child_pipe) < 0) {
err = -errno;
error("pipe(): %s (%d)", strerror(errno), errno);
return err;
err = errno;
error("pipe(): %s (%d)", strerror(err), err);
return -err;
}
child_io = g_io_channel_unix_new(child_pipe[0]);
@ -352,10 +346,10 @@ static int hciops_setup(void)
/* Create and bind HCI socket */
sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
if (sock < 0) {
err = -errno;
error("Can't open HCI socket: %s (%d)", strerror(errno),
errno);
return err;
err = errno;
error("Can't open HCI socket: %s (%d)", strerror(err),
err);
return -err;
}
/* Set filter */
@ -364,9 +358,9 @@ static int hciops_setup(void)
hci_filter_set_event(EVT_STACK_INTERNAL, &flt);
if (setsockopt(sock, SOL_HCI, HCI_FILTER, &flt,
sizeof(flt)) < 0) {
err = -errno;
error("Can't set filter: %s (%d)", strerror(errno), errno);
return err;
err = errno;
error("Can't set filter: %s (%d)", strerror(err), err);
return -err;
}
memset(&addr, 0, sizeof(addr));
@ -374,10 +368,10 @@ static int hciops_setup(void)
addr.hci_dev = HCI_DEV_NONE;
if (bind(sock, (struct sockaddr *) &addr,
sizeof(addr)) < 0) {
err = -errno;
err = errno;
error("Can't bind HCI socket: %s (%d)",
strerror(errno), errno);
return err;
strerror(err), err);
return -err;
}
ctl_io = g_io_channel_unix_new(sock);
@ -427,14 +421,14 @@ static int hciops_start(int index)
goto done; /* on success */
if (errno != EALREADY) {
err = -errno;
err = errno;
error("Can't init device hci%d: %s (%d)",
index, strerror(errno), errno);
index, strerror(err), err);
}
done:
hci_close_dev(dd);
return err;
return -err;
}
static int hciops_stop(int index)
@ -450,14 +444,14 @@ static int hciops_stop(int index)
goto done; /* on success */
if (errno != EALREADY) {
err = -errno;
err = errno;
error("Can't stop device hci%d: %s (%d)",
index, strerror(errno), errno);
index, strerror(err), err);
}
done:
hci_close_dev(dd);
return err;
return -err;
}
static int hciops_powered(int index, gboolean powered)
@ -539,7 +533,7 @@ static int hciops_set_class(int index, uint32_t class)
static int hciops_set_limited_discoverable(int index, uint32_t class,
gboolean limited)
{
int dd, err = 0;
int dd;
int num = (limited ? 2 : 1);
uint8_t lap[] = { 0x33, 0x8b, 0x9e, 0x00, 0x8b, 0x9e };
write_current_iac_lap_cp cp;
@ -556,8 +550,8 @@ static int hciops_set_limited_discoverable(int index, uint32_t class,
cp.num_current_iac = num;
memcpy(&cp.lap, lap, num * 3);
err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_CURRENT_IAC_LAP,
(num * 3 + 1), &cp);
hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_CURRENT_IAC_LAP,
(num * 3 + 1), &cp);
hci_close_dev(dd);
@ -567,7 +561,7 @@ static int hciops_set_limited_discoverable(int index, uint32_t class,
static int hciops_start_discovery(int index, gboolean periodic)
{
uint8_t lap[3] = { 0x33, 0x8b, 0x9e };
int dd, err = 0;
int dd, err;
dd = hci_open_dev(index);
if (dd < 0)
@ -608,7 +602,7 @@ static int hciops_start_discovery(int index, gboolean periodic)
static int hciops_stop_discovery(int index)
{
struct hci_dev_info di;
int dd, err = 0;
int dd, err;
if (hci_devinfo(index, &di) < 0)
return -errno;
@ -634,7 +628,7 @@ static int hciops_stop_discovery(int index)
static int hciops_resolve_name(int index, bdaddr_t *bdaddr)
{
remote_name_req_cp cp;
int dd, err = 0;
int dd, err;
dd = hci_open_dev(index);
if (dd < 0)
@ -657,7 +651,7 @@ static int hciops_resolve_name(int index, bdaddr_t *bdaddr)
static int hciops_set_name(int index, const char *name)
{
change_local_name_cp cp;
int dd, err = 0;
int dd, err;
dd = hci_open_dev(index);
if (dd < 0)
@ -678,7 +672,7 @@ static int hciops_set_name(int index, const char *name)
static int hciops_read_name(int index)
{
int dd, err = 0;
int dd, err;
dd = hci_open_dev(index);
if (dd < 0)
@ -696,7 +690,7 @@ static int hciops_read_name(int index)
static int hciops_cancel_resolve_name(int index, bdaddr_t *bdaddr)
{
remote_name_req_cancel_cp cp;
int dd, err = 0;
int dd, err;
dd = hci_open_dev(index);
if (dd < 0)

View File

@ -451,7 +451,7 @@ int manager_unregister_adapter(int id)
int manager_start_adapter(int id)
{
struct btd_adapter* adapter;
struct btd_adapter *adapter;
int ret;
adapter = manager_find_adapter_by_id(id);