From: Roy Marples Date: Fri, 6 Dec 2013 17:47:52 +0000 (+0000) Subject: Now that we only use dhcpcd-definitions.conf, remove te static var union. X-Git-Tag: v6.2.0~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc22d2773099d2c71aa7c5d917b693ff44841dd2;p=thirdparty%2Fdhcpcd.git Now that we only use dhcpcd-definitions.conf, remove te static var union. --- diff --git a/dhcp-common.c b/dhcp-common.c index ad8fa1d2..8ff27315 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -63,7 +63,7 @@ int make_option_mask(const struct dhcp_opt *dopts, size_t dopts_len, continue; for (i = 0, opt = dopts; i < dopts_len; i++, opt++) { match = 0; - if (strcmp(opt->v.var, token) == 0) + if (strcmp(opt->var, token) == 0) match = 1; else { errno = 0; @@ -510,7 +510,7 @@ dhcp_envoption1(char **env, const char *prefix, if (len < 0) return 0; if (vname) - e = strlen(opt->v.var) + 1; + e = strlen(opt->var) + 1; else e = 0; if (prefix) @@ -524,7 +524,7 @@ dhcp_envoption1(char **env, const char *prefix, return 0; } if (vname) - v += snprintf(val, e, "%s_%s=", prefix, opt->v.var); + v += snprintf(val, e, "%s_%s=", prefix, opt->var); else v += snprintf(val, e, "%s=", prefix); if (len != 0) @@ -564,7 +564,7 @@ dhcp_envoption(char **env, const char *prefix, return 0; } } - e = strlen(prefix) + strlen(opt->v.var) + 2 + + e = strlen(prefix) + strlen(opt->var) + 2 + (opt->type & INDEX ? 3 : 0); pfx = malloc(e); if (pfx == NULL) { @@ -573,9 +573,9 @@ dhcp_envoption(char **env, const char *prefix, } if (opt->type & INDEX) snprintf(pfx, e, "%s_%s%d", prefix, - opt->v.var, ++opt->index); + opt->var, ++opt->index); else - snprintf(pfx, e, "%s_%s", prefix, opt->v.var); + snprintf(pfx, e, "%s_%s", prefix, opt->var); } else pfx = NULL; @@ -590,7 +590,7 @@ dhcp_envoption(char **env, const char *prefix, /* Use the option prefix if the embedded option * name is different. * This avoids new_fqdn_fqdn which would be silly. */ - ov = strcmp(opt->v.var, eopt->v.var); + ov = strcmp(opt->var, eopt->var); if (dhcp_envoption1(env == NULL ? NULL : &env[n], pfx, eopt, ov, od, e, ifname)) n++; diff --git a/dhcp-common.h b/dhcp-common.h index 05b68d0d..fbd7f8a2 100644 --- a/dhcp-common.h +++ b/dhcp-common.h @@ -65,14 +65,7 @@ struct dhcp_opt { uint16_t option; int type; int len; - - /* This union allows us to define a global static list of - * variable names which we don't free and a list of user defined - * options which we do free. */ - union { - char *dvar; - const char *var; - } v; + char *var; int index; /* Index counter for many instances of the same option */ diff --git a/dhcp.c b/dhcp.c index 4711471c..2939e874 100644 --- a/dhcp.c +++ b/dhcp.c @@ -138,7 +138,7 @@ dhcp_printoptions(void) printf(" %s\n", *p); for (i = 0, opt = dhcp_opts; i < dhcp_opts_len; i++, opt++) - printf("%03d %s\n", opt->option, opt->v.var); + printf("%03d %s\n", opt->option, opt->var); } #ifdef DEBUG_MEMORY diff --git a/dhcp6.c b/dhcp6.c index 4a628687..380996be 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -138,7 +138,7 @@ dhcp6_printoptions(void) const struct dhcp_opt *opt; for (i = 0, opt = dhcp6_opts; i < dhcp6_opts_len; i++, opt++) - printf("%05d %s\n", opt->option, opt->v.var); + printf("%05d %s\n", opt->option, opt->var); } static int @@ -2085,7 +2085,7 @@ dhcp6_handledata(__unused void *arg) { syslog(LOG_WARNING, "%s: reject DHCPv6 (no option %s) from %s", - ifp->name, opt->v.var, sfrom); + ifp->name, opt->var, sfrom); return; } } diff --git a/if-options.c b/if-options.c index c3ac2f2f..e85fe11a 100644 --- a/if-options.c +++ b/if-options.c @@ -488,17 +488,18 @@ void free_dhcp_opt_embenc(struct dhcp_opt *opt) { size_t i; + struct dhcp_opt *o; - free(opt->v.dvar); + free(opt->var); - for (i = 0; i < opt->embopts_len; i++) - free(opt->embopts[i].v.dvar); + for (i = 0, o = opt->embopts; i < opt->embopts_len; i++, o++) + free(o->var); free(opt->embopts); opt->embopts_len = 0; opt->embopts = NULL; - for (i = 0; i < opt->encopts_len; i++) - free(opt->encopts[i].v.dvar); + for (i = 0, o = opt->encopts; i < opt->encopts_len; i++, o++) + free(o->var); free(opt->encopts); opt->encopts_len = 0; opt->encopts = NULL; @@ -1402,7 +1403,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg) ndop->option = i; /* could have been 0 */ ndop->type = t; ndop->len = l; - ndop->v.dvar = np; + ndop->var = np; /* Save the define for embed and encap options */ if (opt == O_DEFINE || opt == O_DEFINE6) ldop = ndop;