diff options
author | Harald Welte <laforge@osmocom.org> | 2021-04-25 21:29:22 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-04-25 21:30:47 +0200 |
commit | 8e6ba005d40914cd327cba366b2650af1d7db3a7 (patch) | |
tree | 55383150e2aa2acd00b19899e30d267d2430755e | |
parent | 206d613b4daf14a76fcc1401f477239fe089566a (diff) |
st2-cardem-pcsc: Fix goto-in-while mess
There's some code that wasnts to goto within the while loop, and there's
some other code that wants to goto after the while loop. Don't jump
from outside the while loop into the while loop.
Change-Id: Ic2a94ad034dd259f15712687443b569f0d18ff3f
-rw-r--r-- | host/src/simtrace2-cardem-pcsc.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c index 543780f..931d9d7 100644 --- a/host/src/simtrace2-cardem-pcsc.c +++ b/host/src/simtrace2-cardem-pcsc.c @@ -545,20 +545,20 @@ int main(int argc, char **argv) transp->usb_devh = osmo_libusb_open_claim_interface(NULL, NULL, ifm); if (!transp->usb_devh) { fprintf(stderr, "can't open USB device\n"); - goto close_exit; + goto close; } rc = libusb_claim_interface(transp->usb_devh, if_num); if (rc < 0) { fprintf(stderr, "can't claim interface %d; rc=%d\n", if_num, rc); - goto close_exit; + goto close; } rc = osmo_libusb_get_ep_addrs(transp->usb_devh, if_num, &transp->usb_ep.out, &transp->usb_ep.in, &transp->usb_ep.irq_in); if (rc < 0) { fprintf(stderr, "can't obtain EP addrs; rc=%d\n", rc); - goto close_exit; + goto close; } allocate_and_submit_irq(ci); @@ -587,13 +587,20 @@ int main(int argc, char **argv) ret = 0; libusb_release_interface(transp->usb_devh, 0); -close_exit: - if (transp->usb_devh) + +close: + if (transp->usb_devh) { libusb_close(transp->usb_devh); + transp->usb_devh = NULL; + } if (keep_running) sleep(1); } while (keep_running); +close_exit: + if (transp->usb_devh) + libusb_close(transp->usb_devh); + libusb_exit(NULL); do_exit: return ret; |