[PATCH BlueZ 3/4] obexd: Simplify org.bluez.Error.InvalidArguments handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use a helper function to void code duplication.
---
 obexd/plugins/bluetooth.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index 8985c83..e28a94f 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -104,6 +104,12 @@ drop:
 	return;
 }
 
+static DBusMessage *invalid_args(DBusMessage *msg)
+{
+	return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
+					"Invalid arguments in method call");
+}
+
 static DBusMessage *profile_new_connection(DBusConnection *conn,
 						DBusMessage *msg, void *data)
 {
@@ -115,26 +121,20 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 	dbus_message_iter_init(msg, &args);
 
 	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
-		return g_dbus_create_error(msg,
-					"org.bluez.Error.InvalidArguments",
-					"Invalid arguments in method call");
+		return invalid_args(msg);
 
 	dbus_message_iter_get_basic(&args, &device);
 
 	dbus_message_iter_next(&args);
 
 	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_UNIX_FD)
-		return g_dbus_create_error(msg,
-					"org.bluez.Error.InvalidArguments",
-					"Invalid arguments in method call");
+		return invalid_args(msg);
 
 	dbus_message_iter_get_basic(&args, &fd);
 
 	io = g_io_channel_unix_new(fd);
 	if (io == NULL)
-		return g_dbus_create_error(msg,
-					"org.bluez.Error.InvalidArguments",
-					"Invalid arguments in method call");
+		return invalid_args(msg);
 
 	DBG("device %s", device);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux