summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacio Casal Quinteiro <icq@gnome.org>2014-12-24 11:57:47 +0100
committerIgnacio Casal Quinteiro <icq@gnome.org>2014-12-24 11:57:47 +0100
commit71918ffeb49a6643416bc5093ffbfa27f6d1f305 (patch)
tree8fe82e1d428767dc850615f9c135d2d4efb0e4fd
parent819066b6453df4e7931b23771ccf0dcb2a15f203 (diff)
downloadgusb-71918ffeb49a6643416bc5093ffbfa27f6d1f305.tar.gz
context: there is not need to use gotos
-rw-r--r--gusb/gusb-context.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c
index 613318c..2619fa6 100644
--- a/gusb/gusb-context.c
+++ b/gusb/gusb-context.c
@@ -625,6 +625,7 @@ g_usb_context_find_by_bus_address (GUsbContext *context,
guint i;
g_return_val_if_fail (G_USB_IS_CONTEXT (context), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
priv = context->priv;
@@ -634,16 +635,18 @@ g_usb_context_find_by_bus_address (GUsbContext *context,
if (g_usb_device_get_bus (curr) == bus &&
g_usb_device_get_address (curr) == address) {
device = g_object_ref (curr);
- goto out;
+ break;
}
}
- g_set_error (error,
- G_USB_DEVICE_ERROR,
- G_USB_DEVICE_ERROR_NO_DEVICE,
- "Failed to find device %04x:%04x",
- bus, address);
-out:
+ if (device == NULL) {
+ g_set_error (error,
+ G_USB_DEVICE_ERROR,
+ G_USB_DEVICE_ERROR_NO_DEVICE,
+ "Failed to find device %04x:%04x",
+ bus, address);
+ }
+
return device;
}
@@ -671,6 +674,7 @@ g_usb_context_find_by_vid_pid (GUsbContext *context,
guint i;
g_return_val_if_fail (G_USB_IS_CONTEXT (context), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
priv = context->priv;
@@ -680,16 +684,18 @@ g_usb_context_find_by_vid_pid (GUsbContext *context,
if (g_usb_device_get_vid (curr) == vid &&
g_usb_device_get_pid (curr) == pid) {
device = g_object_ref (curr);
- goto out;
+ break;
}
}
- g_set_error (error,
- G_USB_DEVICE_ERROR,
- G_USB_DEVICE_ERROR_NO_DEVICE,
- "Failed to find device %04x:%04x",
- vid, pid);
-out:
+ if (device == NULL) {
+ g_set_error (error,
+ G_USB_DEVICE_ERROR,
+ G_USB_DEVICE_ERROR_NO_DEVICE,
+ "Failed to find device %04x:%04x",
+ vid, pid);
+ }
+
return device;
}