summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2014-07-20 21:06:56 +0000
committerMarcus Meissner <marcus@jet.franken.de>2014-07-20 21:06:56 +0000
commit543f536273c1d78d2166591b3b747e96e92154a5 (patch)
treee1a68e773b9355c60e940cfa9b5e47219b857b15
parent84cca908a1c0517b276be07f10c8424507e02057 (diff)
downloadlibgphoto2-543f536273c1d78d2166591b3b747e96e92154a5.tar.gz
From: Axel Waggershauser <awagger@web.de>
CHECK -> C_GP, added some more checks git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15091 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--libgphoto2_port/libusb1/libusb1.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c
index de78cc3cc..3e9194afc 100644
--- a/libgphoto2_port/libusb1/libusb1.c
+++ b/libgphoto2_port/libusb1/libusb1.c
@@ -58,7 +58,13 @@
# define N_(String) (String)
#endif
-#define CHECK(result) {int r=(result); if (r<0) return (r);}
+#define C_GP(RESULT) do {\
+ int _r=(RESULT);\
+ if (_r<GP_OK) {\
+ GP_LOG_E ("'%s' failed: %s (%d)", #RESULT, gp_port_result_as_string(_r), _r);\
+ return _r;\
+ }\
+} while(0)
#define C_PARAMS(PARAMS) do {\
if (!(PARAMS)) {\
GP_LOG_E ("Invalid parameters: '%s' is NULL/FALSE.", #PARAMS);\
@@ -177,11 +183,11 @@ gp_port_library_list (GPPortInfoList *list)
/* TODO: make sure libusb_exit gets called in all error paths inside this function */
/* generic matcher. This will catch passed XXX,YYY entries for instance. */
- gp_port_info_new (&info);
+ C_GP (gp_port_info_new (&info));
gp_port_info_set_type (info, GP_PORT_USB);
gp_port_info_set_name (info, "");
gp_port_info_set_path (info, "^usb:");
- CHECK (gp_port_info_list_append (list, info));
+ C_GP (gp_port_info_list_append (list, info));
nrofdevs = libusb_get_device_list (ctx, &devs);
C_MEM (descs = malloc (sizeof(descs[0])*nrofdevs));
@@ -279,7 +285,7 @@ gp_port_library_list (GPPortInfoList *list)
/* Note: We do not skip USB storage. Some devices can support both,
* and the Ricoh erronously reports it.
*/
- gp_port_info_new (&info);
+ C_GP (gp_port_info_new (&info));
gp_port_info_set_type (info, GP_PORT_USB);
gp_port_info_set_name (info, "Universal Serial Bus");
snprintf (path,sizeof(path), "usb:%03d,%03d",
@@ -287,16 +293,16 @@ gp_port_library_list (GPPortInfoList *list)
libusb_get_device_address (devs[d])
);
gp_port_info_set_path (info, path);
- CHECK (gp_port_info_list_append (list, info));
+ C_GP (gp_port_info_list_append (list, info));
}
/* This will only be added if no other device was ever added.
* Users doing "usb:" usage will enter the regular expression matcher case. */
if (nrofdevices == 0) {
- gp_port_info_new (&info);
+ C_GP (gp_port_info_new (&info));
gp_port_info_set_type (info, GP_PORT_USB);
gp_port_info_set_name (info, "Universal Serial Bus");
gp_port_info_set_path (info, "usb:");
- CHECK (gp_port_info_list_append (list, info));
+ C_GP (gp_port_info_list_append (list, info));
}
libusb_exit (ctx); /* should free all stuff above */
free (descs);