diff options
author | Sean McBride <sean@rogue-research.com> | 2018-12-15 16:12:07 -0500 |
---|---|---|
committer | Nathan Hjelm <hjelmn@me.com> | 2019-01-08 18:08:19 -0700 |
commit | 9a23fe1fd1e8b5035c622e3c6d4ae555513dec3c (patch) | |
tree | 6b97d3a6d655baeb313b280ddb9947b0b971af80 | |
parent | dc2c45c87832dc38090911f8ede008ae978a9c91 (diff) | |
download | libusb-9a23fe1fd1e8b5035c622e3c6d4ae555513dec3c.tar.gz |
Removed unneeded checks for passing null to free()
Closes #507
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
-rw-r--r-- | libusb/io.c | 16 | ||||
-rw-r--r-- | libusb/os/darwin_usb.c | 4 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
3 files changed, 8 insertions, 14 deletions
diff --git a/libusb/io.c b/libusb/io.c index 25b5aca..8c2b02a 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1194,8 +1194,7 @@ void usbi_io_exit(struct libusb_context *ctx) usbi_cond_destroy(&ctx->event_waiters_cond); usbi_mutex_destroy(&ctx->event_data_lock); usbi_tls_key_delete(ctx->event_handling_key); - if (ctx->pollfds) - free(ctx->pollfds); + free(ctx->pollfds); } static int calculate_timeout(struct usbi_transfer *transfer) @@ -1297,7 +1296,7 @@ void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer) return; usbi_dbg("transfer %p", transfer); - if (transfer->flags & LIBUSB_TRANSFER_FREE_BUFFER && transfer->buffer) + if (transfer->flags & LIBUSB_TRANSFER_FREE_BUFFER) free(transfer->buffer); itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer); @@ -2106,10 +2105,8 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv) if (ctx->event_flags & USBI_EVENT_POLLFDS_MODIFIED) { usbi_dbg("poll fds modified, reallocating"); - if (ctx->pollfds) { - free(ctx->pollfds); - ctx->pollfds = NULL; - } + free(ctx->pollfds); + ctx->pollfds = NULL; /* sanity check - it is invalid for a context to have fewer than the * required internal fds (memory corruption?) */ @@ -2755,15 +2752,12 @@ out: * Since version 1.0.20, \ref LIBUSB_API_VERSION >= 0x01000104 * * It is legal to call this function with a NULL pollfd list. In this case, - * the function will simply return safely. + * the function will simply do nothing. * * \param pollfds the list of libusb_pollfd structures to free */ void API_EXPORTED libusb_free_pollfds(const struct libusb_pollfd **pollfds) { - if (!pollfds) - return; - free((void *)pollfds); } diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index fde4b6a..46f66ff 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1675,8 +1675,8 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { struct darwin_interface *cInterface; - /* construct an array of IOUSBIsocFrames, reuse the old one if possible */ - if (tpriv->isoc_framelist && tpriv->num_iso_packets != transfer->num_iso_packets) { + /* construct an array of IOUSBIsocFrames, reuse the old one if the sizes are the same */ + if (tpriv->num_iso_packets != transfer->num_iso_packets) { free(tpriv->isoc_framelist); tpriv->isoc_framelist = NULL; } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 0340def..90aad01 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11330 +#define LIBUSB_NANO 11332 |