[PATCH v2 03/12] libusbg: Fix gadget-acm-ecm example to cleanup at exit.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make use of previously unused variable ret to cleanup
afterr successful gadget creation.

Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
Changes since v1:
	- change labels on more suitable for given context

 examples/gadget-acm-ecm.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/examples/gadget-acm-ecm.c b/examples/gadget-acm-ecm.c
index e33ee06..9493613 100644
--- a/examples/gadget-acm-ecm.c
+++ b/examples/gadget-acm-ecm.c
@@ -39,13 +39,13 @@ int main(void)
 	s = gadget_init("/config");
 	if (!s) {
 		fprintf(stderr, "Error on USB gadget init\n");
-		goto error1;
+		goto out1;
 	}
 
 	g = gadget_create_gadget(s, "g1", VENDOR, PRODUCT);
 	if (!g) {
 		fprintf(stderr, "Error on create gadget\n");
-		goto error2;
+		goto out2;
 	}
 	gadget_set_gadget_serial_number(g, LANG_US_ENG, "0123456789");
 	gadget_set_gadget_manufacturer(g, LANG_US_ENG, "Foo Inc.");
@@ -54,25 +54,25 @@ int main(void)
 	f_acm0 = gadget_create_function(g, F_ACM, "usb0");
 	if (!f_acm0) {
 		fprintf(stderr, "Error creating acm0 function\n");
-		goto error2;
+		goto out2;
 	}
 
 	f_acm1 = gadget_create_function(g, F_ACM, "usb1");
 	if (!f_acm1) {
 		fprintf(stderr, "Error creating acm1 function\n");
-		goto error2;
+		goto out2;
 	}
 
 	f_ecm = gadget_create_function(g, F_ECM, "usb0");
 	if (!f_ecm) {
 		fprintf(stderr, "Error creating ecm function\n");
-		goto error2;
+		goto out2;
 	}
 
 	c = gadget_create_config(g, "c.1");
 	if (!c) {
 		fprintf(stderr, "Error creating config\n");
-		goto error2;
+		goto out2;
 	}
 	gadget_set_config_string(c, LANG_US_ENG, "CDC 2xACM+ECM");
 	gadget_add_config_function(c, "acm.GS0", f_acm0);
@@ -81,11 +81,11 @@ int main(void)
 
 	gadget_enable_gadget(g, DEFAULT_UDC);
 
-	return 0;
+	ret = 0;
 
-error2:
+out2:
 	gadget_cleanup(s);
 
-error1:
-	return -EINVAL;
+out1:
+	return ret;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux