diff options
author | Sean McBride <sean@rogue-research.com> | 2024-01-01 23:46:06 -0500 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2024-04-04 09:02:32 +0200 |
commit | 43107c84e4a5f6b15c296eff8cc3578100f35dce (patch) | |
tree | 5a290ae0754cce5d28cab8bdc95ffcaf4db1f36b | |
parent | 1c1bad9d128052fa82ba2c648875276f0189c3a2 (diff) | |
download | libusb-43107c84e4a5f6b15c296eff8cc3578100f35dce.tar.gz |
darwin: Suppress false positive warning with an assert
The clang static analyzer doesn't see that the pointer will always be
non-NULL if the return value is success. Just assert this fact so that
it can see this, and then it won't warn:
Access to field 'can_enumerate' results in a dereference of a null
pointer (loaded from variable 'cached_device')
References #1414
-rw-r--r-- | libusb/os/darwin_usb.c | 3 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index c129cf5..bcfa3ca 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1362,6 +1362,8 @@ static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io usbi_mutex_unlock(&darwin_cached_devices_mutex); + assert((ret == LIBUSB_SUCCESS) ? (*cached_out != NULL) : true); + return ret; } @@ -1472,6 +1474,7 @@ static enum libusb_error darwin_scan_devices(struct libusb_context *ctx) { while ((service = IOIteratorNext (deviceIterator))) { ret = darwin_get_cached_device (ctx, service, &cached_device, &old_session_id); + assert((ret >= 0) ? (cached_device != NULL) : true); if (ret < 0 || !cached_device->can_enumerate) { continue; } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index daf8db4..a859d27 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11892 +#define LIBUSB_NANO 11893 |