Skip to contentSkip to conversation

CUPS fixes

PATCH In review Bastien Nocera 2 participants 4 messages Aug 11, 2009 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CUPS fixes

The CUPS backend would be aborting when scanning for a printer that's not in bluetoothd known devices. Fixes both bugs I found in my testing.

Cheers

Quoted 1 line

From 35ffd5a6dafd7e38c7d8c9502608314a44919302 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Tue, 11 Aug 2009 12:23:39 +0100
Subject: [PATCH 1/2] Don't abort cups backend on property change

Make sure the cups backend doesn't abort when trying to access a property that's not Discovering.

---
 cups/main.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
cups/main.c +3 -0
index 2fbfe7e..9c24734 100644
@@ -506,6 +506,9 @@ static DBusHandlerResult filter_func(DBusConnection *connection, DBusMessage *me
 
 		dbus_message_iter_init(message, &iter);
 		dbus_message_iter_get_basic(&iter, &name);
+		if (name == NULL ||
+		    strcmp(name, "Discovering") != 0)
+		    	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 		dbus_message_iter_next(&iter);
 		dbus_message_iter_recurse(&iter, &value_iter);
 		dbus_message_iter_get_basic(&value_iter, &discovering);
Signature · 1 line
1.6.2.5
Quoted 1 line

From b29e1cb433454391da92720c3ff87373d9d60500 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Tue, 11 Aug 2009 12:24:58 +0100
Subject: [PATCH 2/2] Actually read the CreateDevice reply

Fixes aborts when the printer isn't a known device.

---
 cups/main.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
cups/main.c +3 -3
index 9c24734..ba9864f 100644
@@ -371,9 +371,9 @@ static void remote_device_found(const char *adapter, const char *bdaddr, const c
 
 		if (!reply)
 			return;
-	} else {
-		if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID) == FALSE)
-			return;
+	}
+	if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID) == FALSE) {
+		return;
 	}
 
 	id = device_get_ieee1284_id(adapter, object_path);
Signature · 1 line
1.6.2.5
maintainer
#1 lore raw

Hi Bastien,

Quoted 2 lines

The CUPS backend would be aborting when scanning for a printer that's not in bluetoothd known devices. Fixes both bugs I found in my testing.

can we at least try to keep the coding style. I don't really know what is so hard about it.

                dbus_message_iter_get_basic(&iter, &name);
+               if (name == NULL ||
+                   strcmp(name, "Discovering") != 0)
+                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
                dbus_message_iter_next(&iter);

The NULL check and strcmp can go on the same line here.

                if (!reply)
                        return;

- } else {
- if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID) == FALSE)
- return;
+ }
+ if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID) == FALSE) {

+               return;
        }

I know that the previous one exceeded the 80 char limit, but no need to keep it.

Regards

Marcel

#2 lore raw
Quoted 7 lines · Marcel Holtmann

Hi Bastien,

Quoted 2 lines

The CUPS backend would be aborting when scanning for a printer that's not in bluetoothd known devices. Fixes both bugs I found in my testing.

can we at least try to keep the coding style. I don't really know what is so hard about it.

Thanks for all the love.

Updated patches attached.

Quoted 1 line

From ca7080b84cae508564e67fc793be926ef2074efe Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Tue, 11 Aug 2009 23:26:43 +0100
Subject: [PATCH 1/2] Don't abort cups backend on property change

Make sure the cups backend doesn't abort when trying to access a property that's not Discovering.

---
 cups/main.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
cups/main.c +2 -0
index fda3339..96a2e56 100644
@@ -506,6 +506,8 @@ static DBusHandlerResult filter_func(DBusConnection *connection, DBusMessage *me
 
 		dbus_message_iter_init(message, &iter);
 		dbus_message_iter_get_basic(&iter, &name);
+		if (name == NULL || strcmp(name, "Discovering") != 0)
+			return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 		dbus_message_iter_next(&iter);
 		dbus_message_iter_recurse(&iter, &value_iter);
 		dbus_message_iter_get_basic(&value_iter, &discovering);
Signature · 1 line
1.6.2.5
Quoted 1 line

From 5fff32b4eacb959c009495a5384bf245b1b3a285 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Tue, 11 Aug 2009 23:27:56 +0100
Subject: [PATCH 2/2] Actually read the CreateDevice reply

Fixes aborts when the printer isn't a known device.

---
 cups/main.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
cups/main.c +4 -3
index 96a2e56..da757b0 100644
@@ -371,9 +371,10 @@ static void remote_device_found(const char *adapter, const char *bdaddr, const c
 
 		if (!reply)
 			return;
-	} else {
-		if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID) == FALSE)
-			return;
+	}
+	if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path,
+				  DBUS_TYPE_INVALID) == FALSE) {
+		return;
 	}
 
 	id = device_get_ieee1284_id(adapter, object_path);
Signature · 1 line
1.6.2.5
maintainer
#3 lore raw

Hi Bastien,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

The CUPS backend would be aborting when scanning for a printer that's not in bluetoothd known devices. Fixes both bugs I found in my testing.

can we at least try to keep the coding style. I don't really know what is so hard about it.

Thanks for all the love.

you know that I am picky with this ;)

Quoted 1 line

Updated patches attached.

Patches have been applied. Thanks.

Regards

Marcel