Cleanup patch from Denis Vlasenko. Mostly variants of removing the if(x)

from before "if(x) free(x)".
This commit is contained in:
Rob Landley
2006-03-01 16:39:45 +00:00
parent 93f2286e6e
commit e7c43b66d7
33 changed files with 139 additions and 281 deletions

View File

@@ -1356,16 +1356,15 @@ extern int ifupdown_main(int argc, char **argv)
} else {
/* Remove an interface from the linked list */
if (iface_state) {
/* This needs to be done better */
const llist_t *link = iface_state->link;
free(iface_state->data);
free(iface_state->link);
if (iface_state->link) {
iface_state->data = iface_state->link->data;
iface_state->link = iface_state->link->link;
} else {
iface_state->data = NULL;
iface_state->link = NULL;
iface_state->data = NULL;
iface_state->link = NULL;
if (link) {
iface_state->data = link->data;
iface_state->link = link->link;
}
free(link);
}
}
}

View File

@@ -413,8 +413,7 @@ static void freeconfig (servtab_t *cp)
free (cp->se_group);
free (cp->se_server);
for (i = 0; i < MAXARGV; i++)
if (cp->se_argv[i])
free (cp->se_argv[i]);
free (cp->se_argv[i]);
}
static int bump_nofile (void)

View File

@@ -902,10 +902,8 @@ gethostinfo(const char *host)
static void
freehostinfo(struct hostinfo *hi)
{
if (hi->name != NULL) {
free(hi->name);
hi->name = NULL;
}
free(hi->name);
hi->name = NULL;
free((char *)hi->addrs);
free((char *)hi);
}

View File

@@ -217,7 +217,7 @@ int main(int argc, char *argv[])
case 'c':
if (no_clientid) show_usage();
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
if (client_config.clientid) free(client_config.clientid);
free(client_config.clientid);
client_config.clientid = xmalloc(len + 2);
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
client_config.clientid[OPT_LEN] = len;
@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
break;
case 'V':
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
if (client_config.vendorclass) free(client_config.vendorclass);
free(client_config.vendorclass);
client_config.vendorclass = xmalloc(len + 2);
client_config.vendorclass[OPT_CODE] = DHCP_VENDOR;
client_config.vendorclass[OPT_LEN] = len;
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
case 'h':
case 'H':
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
if (client_config.hostname) free(client_config.hostname);
free(client_config.hostname);
client_config.hostname = xmalloc(len + 2);
client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
client_config.hostname[OPT_LEN] = len;
@@ -253,7 +253,7 @@ int main(int argc, char *argv[])
break;
case 'F':
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
if (client_config.fqdn) free(client_config.fqdn);
free(client_config.fqdn);
client_config.fqdn = xmalloc(len + 5);
client_config.fqdn[OPT_CODE] = DHCP_FQDN;
client_config.fqdn[OPT_LEN] = len + 3;

View File

@@ -62,7 +62,7 @@ static int read_str(const char *line, void *arg)
{
char **dest = arg;
if (*dest) free(*dest);
free(*dest);
*dest = strdup(line);
return 1;