]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Now that we only use dhcpcd-definitions.conf, remove te static var union.
authorRoy Marples <roy@marples.name>
Fri, 6 Dec 2013 17:47:52 +0000 (17:47 +0000)
committerRoy Marples <roy@marples.name>
Fri, 6 Dec 2013 17:47:52 +0000 (17:47 +0000)
dhcp-common.c
dhcp-common.h
dhcp.c
dhcp6.c
if-options.c

index ad8fa1d2d7f74ba122423996a7a2241504f9e476..8ff273156392c754e79019d2322e34bd26629b28 100644 (file)
@@ -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++;
index 05b68d0d9894e786cf58032e392044932272cdc5..fbd7f8a2f035a4760e99287f5c65fbf00b5fcfc6 100644 (file)
@@ -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 4711471c16a34153c4a624dfb291ff506bf603ec..2939e874c223fde4424a88b916c218876118e128 100644 (file)
--- 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 4a628687757f9088aafac08fe4812643c86027b0..380996bec202a0877d546402036101ba663fb7ae 100644 (file)
--- 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;
                }
        }
index c3ac2f2fa77b64cdca0050409907a29a8ef7ab2c..e85fe11a6d12ca37da8fbb7b4c2beedaaf8ae736 100644 (file)
@@ -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;