Change in simtrace2[master]: st2-cardem-pcsc: Fix goto-in-while mess

laforge gerrit-no-reply at lists.osmocom.org
Sun Apr 25 19:35:27 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/23898 )

Change subject: st2-cardem-pcsc: Fix goto-in-while mess
......................................................................

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
---
M host/src/simtrace2-cardem-pcsc.c
1 file changed, 12 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



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 @@
 		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 @@
 		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;

-- 
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23898
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic2a94ad034dd259f15712687443b569f0d18ff3f
Gerrit-Change-Number: 23898
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210425/68be77d8/attachment.htm>


More information about the gerrit-log mailing list