From f2bbe516aeb41d33729cfa0a35c2179c246a5b7f Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakobols@kth.se>
Date: Tue, 12 Jun 2018 09:24:56 +0200
Subject: [PATCH] slight refactor on error handling inside get_device_name

---
 dongle.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/dongle.c b/dongle.c
index 3cca1c7..233f236 100644
--- a/dongle.c
+++ b/dongle.c
@@ -441,9 +441,10 @@ int get_devices_from_path(char *input_path)
 			continue;
 
 		dev = (struct device *)calloc(1, sizeof(*dev));
-		if (!dev) {
-			perror("calloc");
-			goto fail_dev;
+		if (!dev) { //what is correct error handling here? goto inside while? outside while? continue?
+			/*perror("calloc");
+			goto fail_dev;*/
+			continue;
 		}
 
 		dev->usb.product = get_usb_stat(path, "product");
@@ -457,8 +458,6 @@ int get_devices_from_path(char *input_path)
 	}
 	closedir(dir);
 	return 0;
-fail_dev:
-	closedir(dir);
 fail_dr:
 	return -1;
 }
@@ -525,7 +524,6 @@ char *get_device_ip(char *device_name)
 		if (strncmp(iface, device_name, 10) != 0)
 			continue;
 
-		printf("iface %s");
 		host_flag = atoi(flags) & 4;
 		if (!host_flag)
 			continue;
-- 
GitLab