diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2014-07-22 21:00:32 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2014-07-22 21:00:32 +0000 |
commit | b06e5d1216b775d0f6cdee97d82d30fcd46912e9 (patch) | |
tree | 0d2191886a72f7c23016c52efddc1b556fae0c04 /libgphoto2_port/usbscsi | |
parent | 6c5db352a61dff5506e154d0bfbf82a8b7542d0e (diff) | |
download | libgphoto2-b06e5d1216b775d0f6cdee97d82d30fcd46912e9.tar.gz |
From: Axel Waggershauser <awagger@web.de>
1) introduce C_PARAMS and C_PARAMS_MSG along the lines of C_MEM
2) replace CHECK_NULL with C_PARAMS
3) replace the pattern
if ( something ) return GP_ERROR_BAD_PARAMETERS;
with
C_PARAMS ( !something );
I went over the whole patch again to check that each 'something'
condition is really inverted, so I dare to suggest you don't have to
do that again ;).
4) replaced CHECK_LIST and CHECK_INDEX_RANGE with simple one-line
C_PARAMS(...) expressions
5) a couple of hunks look like this
- if (!inet_aton (buffer, &inp)) {
- fprintf(stderr,"failed to scan for addr in %s\n", buffer);
- return GP_ERROR_BAD_PARAMETERS;
- }
+ C_PARAMS_MSG (inet_aton (buffer, &inp),
so some 'lost' error messages get now properly piped into the gp_log
mechanism.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15103 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/usbscsi')
-rw-r--r-- | libgphoto2_port/usbscsi/linux.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libgphoto2_port/usbscsi/linux.c b/libgphoto2_port/usbscsi/linux.c index 6d2172062..63435afd4 100644 --- a/libgphoto2_port/usbscsi/linux.c +++ b/libgphoto2_port/usbscsi/linux.c @@ -252,8 +252,7 @@ gp_port_usbscsi_init (GPPort *port) static int gp_port_usbscsi_exit (GPPort *port) { - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); free (port->pl); port->pl = NULL; @@ -314,8 +313,7 @@ static int gp_port_usbscsi_send_scsi_cmd (GPPort *port, int to_dev, char *cmd, #ifdef HAVE_SCSI_SG_H sg_io_hdr_t io_hdr; - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); /* The device needs to be opened for that operation */ if (port->pl->fd == -1) @@ -357,8 +355,7 @@ static int gp_port_usbscsi_send_scsi_cmd (GPPort *port, int to_dev, char *cmd, static int gp_port_usbscsi_update (GPPort *port) { - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); memcpy (&port->settings, &port->settings_pending, sizeof (port->settings)); @@ -372,12 +369,10 @@ gp_port_usbscsi_find_device(GPPort *port, int idvendor, int idproduct) unsigned short vendor_id, product_id; const char *sg; - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); sg = strrchr (port->settings.usbscsi.path, '/'); - if (!sg) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (sg); sg++; CHECK (gp_port_usbscsi_get_usb_id (sg, &vendor_id, &product_id)) |