From: Johan Hedberg <johan.hedberg@nokia.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] [PATCH] dbus.c cleanup
Date: Thu, 3 Nov 2005 09:20:33 +0200 [thread overview]
Message-ID: <20051103072032.GA28568@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
Hi Marcel,
Here's a cleanup patch for dbus.c which fixes some issues with
whitespace, coding-style, unecessary variables, etc.
I've also fixed PeriodicInquiry functionality of the python test script
(http://www.iki.fi/~jhedberg/bluez-python/pybt.py). It should now
support all currently implemented D-BUS services in hcid. Do you think
it would be worth including it in the bluez-utils cvs?
Johan
[-- Attachment #2: cleanup.patch --]
[-- Type: text/plain, Size: 5065 bytes --]
Index: hcid/dbus.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.c,v
retrieving revision 1.44
diff -u -r1.44 dbus.c
--- hcid/dbus.c 2 Nov 2005 18:46:46 -0000 1.44
+++ hcid/dbus.c 3 Nov 2005 07:12:24 -0000
@@ -106,7 +106,7 @@
typedef struct {
uint32_t code;
const char *str;
-}bluez_error_t;
+} bluez_error_t;
typedef struct {
char *str;
@@ -381,14 +381,15 @@
static gboolean register_dbus_path(const char *path, uint16_t path_id, uint16_t dev_id,
const DBusObjectPathVTable *pvtable, gboolean fallback)
{
- struct hci_dbus_data *data;
+ gboolean ret = FALSE;
+ struct hci_dbus_data *data = NULL;
syslog(LOG_INFO,"Registering DBUS Path: %s", path);
data = malloc(sizeof(struct hci_dbus_data));
if (data == NULL) {
syslog(LOG_ERR,"Failed to alloc memory to DBUS path register data (%s)", path);
- return FALSE;
+ goto out;
}
data->path_id = path_id;
@@ -396,19 +397,23 @@
if (fallback) {
if (!dbus_connection_register_fallback(connection, path, pvtable, data)) {
- syslog(LOG_ERR,"DBUS failed to register %s object", path);
- free(data);
- return FALSE;
+ syslog(LOG_ERR,"DBUS failed to register %s fallback", path);
+ goto out;
}
} else {
if (!dbus_connection_register_object_path(connection, path, pvtable, data)) {
syslog(LOG_ERR,"DBUS failed to register %s object", path);
- free(data);
- return FALSE;
+ goto out;
}
}
- return TRUE;
+ ret = TRUE;
+
+out:
+ if (!ret && data)
+ free(data);
+
+ return ret;
}
static gboolean unregister_dbus_path(const char *path)
@@ -468,8 +473,7 @@
failed:
dbus_message_unref(message);
- hci_send_cmd(dev, OGF_LINK_CTL,
- OCF_PIN_CODE_NEG_REPLY, 6, &ci->bdaddr);
+ hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, &ci->bdaddr);
}
void hcid_dbus_inquiry_start(bdaddr_t *local)
@@ -506,10 +510,7 @@
failed:
dbus_message_unref(message);
-
bt_free(local_addr);
-
- return;
}
void hcid_dbus_inquiry_complete(bdaddr_t *local)
@@ -546,10 +547,7 @@
failed:
dbus_message_unref(message);
-
bt_free(local_addr);
-
- return;
}
void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, int8_t rssi)
@@ -598,8 +596,6 @@
bt_free(local_addr);
bt_free(peer_addr);
-
- return;
}
void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name)
@@ -645,8 +641,6 @@
bt_free(local_addr);
bt_free(peer_addr);
-
- return;
}
void hcid_dbus_remote_name_failed(bdaddr_t *local, bdaddr_t *peer, uint8_t status)
@@ -692,8 +686,6 @@
bt_free(local_addr);
bt_free(peer_addr);
-
- return;
}
void hcid_dbus_conn_complete(bdaddr_t *local, bdaddr_t *peer)
@@ -910,7 +902,6 @@
unregister_dbus_path(DEVICE_PATH);
unregister_dbus_path(MANAGER_PATH);
-
}
gboolean hcid_dbus_register_device(uint16_t id)
@@ -1046,7 +1037,7 @@
for (; ptr->id != INVALID_PATH_ID; ptr++) {
if (ptr->unreg_func(connection, id) < 0)
- goto failed;
+ syslog(LOG_ERR, "Unregistering profile id %04X failed", ptr->id);
}
up_adapters--;
@@ -1161,8 +1152,6 @@
const struct service_data *handlers = NULL;
DBusMessage *reply = NULL;
struct hci_dbus_data *dbus_data = data;
- int type;
- const char *iface;
const char *method;
const char *signature;
const char *path;
@@ -1170,8 +1159,6 @@
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
path = dbus_message_get_path(msg);
- type = dbus_message_get_type(msg);
- iface = dbus_message_get_interface(msg);
method = dbus_message_get_member(msg);
signature = dbus_message_get_signature(msg);
@@ -1216,11 +1203,9 @@
if (error)
reply = bluez_new_failure_msg(msg, error);
-
if (reply) {
- if (!dbus_connection_send (conn, reply, NULL)) {
+ if (!dbus_connection_send (conn, reply, NULL))
syslog(LOG_ERR, "Can't send reply message!");
- }
dbus_message_unref (reply);
}
@@ -1240,7 +1225,7 @@
path = dbus_message_get_path(msg);
iface = dbus_message_get_interface(msg);
- method = dbus_message_get_member (msg);
+ method = dbus_message_get_member(msg);
signature = dbus_message_get_signature(msg);
syslog (LOG_INFO, "%s - path:%s", __PRETTY_FUNCTION__, path);
@@ -1264,11 +1249,9 @@
if (error)
reply = bluez_new_failure_msg(msg, error);
-
if (reply) {
- if (!dbus_connection_send (conn, reply, NULL)) {
+ if (!dbus_connection_send (conn, reply, NULL))
syslog(LOG_ERR, "Can't send reply message!");
- }
dbus_message_unref (reply);
}
@@ -1505,13 +1488,10 @@
if (hci_switch_role(dd, &bdaddr, role, 10000) < 0) {
syslog(LOG_ERR, "Switch role request failed\n");
reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET + errno);
- } else {
- uint8_t result = 0;
- /* return TRUE to indicate that operation was completed */
- reply = dbus_message_new_method_return(msg);
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE, &result);
+ goto failed;
}
+
+ reply = dbus_message_new_method_return(msg);
failed:
return reply;
next reply other threads:[~2005-11-03 7:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-03 7:20 Johan Hedberg [this message]
2005-11-03 8:34 ` [Bluez-devel] [PATCH] dbus.c cleanup Marcel Holtmann
2005-11-03 8:54 ` Johan Hedberg
2005-11-03 9:08 ` Marcel Holtmann
2005-11-03 9:23 ` Johan Hedberg
2005-11-03 9:41 ` Marcel Holtmann
2005-11-03 10:13 ` Johan Hedberg
2005-11-03 10:33 ` Marcel Holtmann
2005-11-03 14:22 ` Johan Hedberg
2005-11-03 14:36 ` Marcel Holtmann
-- strict thread matches above, loose matches on Subject: below --
2005-10-29 17:53 Johan Hedberg
2005-10-29 18:07 ` Marcel Holtmann
2005-10-29 18:48 ` Johan Hedberg
2005-10-29 19:07 ` Marcel Holtmann
2005-10-31 11:59 ` Claudio Takahasi
2005-10-31 12:07 ` Johan Hedberg
2005-10-31 12:14 ` Marcel Holtmann
2005-10-31 12:30 ` Eduardo Rocha
2005-10-31 12:12 ` Marcel Holtmann
2005-10-31 13:47 ` Claudio Takahasi
2005-11-01 13:11 ` Marcel Holtmann
2005-11-01 13:21 ` Claudio Takahasi
2005-11-01 19:08 ` Claudio Takahasi
2005-11-01 19:58 ` Marcel Holtmann
2005-11-01 20:23 ` Johan Hedberg
2005-11-01 20:40 ` Marcel Holtmann
2005-11-01 20:53 ` Claudio Takahasi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051103072032.GA28568@localhost.localdomain \
--to=johan.hedberg@nokia.com \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.