examples: Fix device handle leak in xusb
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 24 Aug 2017 22:52:39 +0000 (15:52 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 24 Aug 2017 22:52:39 +0000 (15:52 -0700)
commitb4c9b4272d61cecffeddeb91abd31efe256a6224
tree198152a5a12a382d1a8561acf2fa698058a1a9aa
parent2cefbc80f26170cdb8e1bbe14de9c08d6c41dafa
examples: Fix device handle leak in xusb

The CALL_CHECK macro returns from the current function, so in the
test_device() function the device handle was being leaked when one of
the functions failed. This commit adds a new CALL_CHECK_CLOSE macro that
does the same as CALL_CHECK but also closes the device handle before
returning. In addition, the macros are changed to declare their needed
variable rather than relying on the variable to already exist within the
scope of the function.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
examples/xusb.c
libusb/version_nano.h