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/usbdiskdirect/linux.c | |
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/usbdiskdirect/linux.c')
-rw-r--r-- | libgphoto2_port/usbdiskdirect/linux.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/libgphoto2_port/usbdiskdirect/linux.c b/libgphoto2_port/usbdiskdirect/linux.c index 8d0dba53e..8b7b86bea 100644 --- a/libgphoto2_port/usbdiskdirect/linux.c +++ b/libgphoto2_port/usbdiskdirect/linux.c @@ -255,8 +255,7 @@ gp_port_usbdiskdirect_init (GPPort *port) static int gp_port_usbdiskdirect_exit (GPPort *port) { - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); free (port->pl); port->pl = NULL; @@ -316,8 +315,7 @@ static int gp_port_usbdiskdirect_seek (GPPort *port, int offset, int whence) { off_t ret; - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (!port); /* The device needs to be opened for that operation */ if (port->pl->fd == -1) @@ -339,8 +337,7 @@ gp_port_usbdiskdirect_write (GPPort *port, const char *bytes, int size) { int ret; - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); /* The device needs to be opened for that operation */ if (port->pl->fd == -1) @@ -361,8 +358,7 @@ gp_port_usbdiskdirect_read (GPPort *port, char *bytes, int size) { int ret; - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); /* The device needs to be opened for that operation */ if (port->pl->fd == -1) @@ -381,8 +377,7 @@ gp_port_usbdiskdirect_read (GPPort *port, char *bytes, int size) static int gp_port_usbdiskdirect_update (GPPort *port) { - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); memcpy (&port->settings, &port->settings_pending, sizeof (port->settings)); @@ -396,12 +391,10 @@ gp_port_usbdiskdirect_find_device(GPPort *port, int idvendor, int idproduct) unsigned short vendor_id, product_id; const char *disk; - if (!port) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (port); disk = strrchr (port->settings.usbdiskdirect.path, '/'); - if (!disk) - return GP_ERROR_BAD_PARAMETERS; + C_PARAMS (disk); disk++; CHECK (gp_port_usbdiskdirect_get_usb_id (disk, |