# HG changeset patch # User Michiel Broek # Date 1406827794 -7200 # Node ID 493e39bb0a0845eb8da3fb5783a578b8a50b1ae9 # Parent 87bfa951ffc2e0beabb67984f0737ecf150d0e17 Small fixes for device configuration diff -r 87bfa951ffc2 -r 493e39bb0a08 thermferm/devices.c --- 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++; diff -r 87bfa951ffc2 -r 493e39bb0a08 thermferm/rdconfig.c --- a/thermferm/rdconfig.c Thu Jul 31 17:52:41 2014 +0200 +++ b/thermferm/rdconfig.c Thu Jul 31 19:29:54 2014 +0200 @@ -47,6 +47,7 @@ units_list *tmp2; profiles_list *tmp3; prof_step *tmp4; + devices_list *device; if (Config.name) free(Config.name); @@ -103,6 +104,19 @@ } Config.profiles = NULL; + for (device = Config.devices; device; device = device->next) { + if (device->uuid) + free(device->uuid); + if (device->address) + free(device->address); + if (device->description) + free(device->description); + if (device->comment) + free(device->comment); + free(device); + } + Config.devices = NULL; + #ifdef HAVE_WIRINGPI_H Config.lcd_cols = 16; Config.lcd_rows = 2; @@ -1156,7 +1170,7 @@ device->gpiopin = ival; xmlFree(key); } - if ((!xmlStrcmp(cur->name, (const xmlChar *)"DESCRPTION"))) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"DESCRIPTION"))) { device->description = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); } if ((!xmlStrcmp(cur->name, (const xmlChar *)"INUSE"))) {