thermferm/devices.c

changeset 161
493e39bb0a08
parent 158
f1b7e2ef90be
child 162
6fc9e3f7962f
--- a/thermferm/devices.c	Thu Jul 31 17:52:41 2014 +0200
+++ b/thermferm/devices.c	Thu Jul 31 19:29:54 2014 +0200
@@ -41,7 +41,7 @@
     DIR			*fd;
     devices_list	*device, *ndev;
     int			found, subdevices, i, rc = 0;
-    char		*family;
+    char		family[3];
     uuid_t		uu;
 
     /*
@@ -52,15 +52,15 @@
 	    if (de->d_name[0] != '.') {
 		found = FALSE;
 		for (device = Config.devices; device; device = device->next) {
-		    if (strcmp(device->address ,de->d_name) == 0) {
+		    if (strcmp(device->address,de->d_name) == 0) {
 			found = TRUE;
 			break;
 		    }
 		}
 
 		if (found == FALSE) {
-		    family = malloc(3);
 		    strncpy(family, de->d_name, 2);
+		    family[2] = '\0';
 		    subdevices = 1;
 		    if (strcmp(family, (char *)"29") == 0)
 			subdevices = 8;
@@ -103,9 +103,10 @@
 			    Config.devices = ndev;
 			} else {
 			    for (device = Config.devices; device; device = device->next) {
-				if (device->next == NULL)
+				if (device->next == NULL) {
 				    device->next = ndev;
-				break;
+				    break;
+				}
 			    }
 			}
 			rc++;

mercurial