diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 91fbf24c2c8a..c35127c49cf8 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -125,8 +125,8 @@ struct device cur; struct device *curp = 0; -char *temp_id; -char *val_id; + +#define ns(s) strdup(s) %} %% @@ -188,17 +188,16 @@ Config_spec: struct cputype *cp = (struct cputype *)malloc(sizeof (struct cputype)); memset(cp, 0, sizeof(*cp)); - cp->cpu_name = ns($2); + cp->cpu_name = $2; cp->cpu_next = cputype; cputype = cp; - free(temp_id); } | OPTIONS Opt_list | MAKEOPTIONS Mkopt_list | IDENT ID - = { ident = ns($2); } | + = { ident = $2; } | System_spec | MAXUSERS NUMBER @@ -397,7 +396,7 @@ Option: struct opt *op = (struct opt *)malloc(sizeof (struct opt)); char *s; memset(op, 0, sizeof(*op)); - op->op_name = ns($1); + op->op_name = $1; op->op_next = opt; op->op_value = 0; opt = op; @@ -406,34 +405,31 @@ Option: *s = '\0'; op->op_value = ns(s + 1); } - free(temp_id); } | Save_id EQUALS Opt_value = { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); memset(op, 0, sizeof(*op)); - op->op_name = ns($1); + op->op_name = $1; op->op_next = opt; - op->op_value = ns($3); + op->op_value = $3; opt = op; - free(temp_id); - free(val_id); } ; Opt_value: ID - = { $$ = val_id = ns($1); } | + = { $$ = $1; } | NUMBER = { char nb[16]; (void) sprintf(nb, "%d", $1); - $$ = val_id = ns(nb); + $$ = ns(nb); } ; Save_id: ID - = { $$ = temp_id = ns($1); } + = { $$ = $1; } ; Mkopt_list: @@ -447,18 +443,16 @@ Mkoption: = { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); memset(op, 0, sizeof(*op)); - op->op_name = ns($1); + op->op_name = $1; op->op_ownfile = 0; /* for now */ op->op_next = mkopt; - op->op_value = ns($3); + op->op_value = $3; mkopt = op; - free(temp_id); - free(val_id); } ; Dev: ID - = { $$ = ns($1); } + = { $$ = $1; } ; Device_spec: @@ -620,7 +614,7 @@ Info: IOSIZ NUMBER = { cur.d_msize = $2; } | PORT device_name - = { cur.d_port = ns($2); } | + = { cur.d_port = $2; } | PORT NUMBER = { cur.d_portn = $2; } | PORT AUTO @@ -671,20 +665,6 @@ yyerror(s) fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); } -/* - * return the passed string in a new space - */ -char * -ns(str) - register char *str; -{ - register char *cp; - - cp = malloc((unsigned)(strlen(str)+1)); - (void) strcpy(cp, str); - return (cp); -} - /* * add a device to the list of devices */ diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index bfa56926f479..735658d24495 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -40,10 +40,13 @@ static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; */ #include +#include #include #include "config.h" #include "y.tab.h" +#define ns(s) strdup(s) + headers() { register struct file_list *fl; @@ -157,7 +160,7 @@ do_header(dev, hname, count) if (oldcount == -1) { fl = (struct file_list *) malloc(sizeof *fl); bzero(fl, sizeof(*fl)); - fl->f_fn = ns(name); /* malloced */ + fl->f_fn = ns(name); fl->f_type = count; fl->f_next = fl_head; fl_head = fl; diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 513a5037a73c..56aa44a44eab 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93"; */ #include +#include #include #include "y.tab.h" #include "config.h" @@ -61,6 +62,8 @@ static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93"; wd = word; \ } +#define ns(s) strdup(s) + static struct file_list *fcur; char *tail(); extern int old_config_present; diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c index 40fe87e82974..aea47b676f09 100644 --- a/usr.sbin/config/mkoptions.c +++ b/usr.sbin/config/mkoptions.c @@ -41,10 +41,15 @@ static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; */ #include +#include #include #include "config.h" #include "y.tab.h" +#define ns(s) strdup(s) + +static char *lower __P((char *)); + options() { struct opt_list *ol; @@ -57,7 +62,7 @@ options() for (cp = cputype; cp; cp = cp->cpu_next) { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); memset(op, 0, sizeof(*op)); - op->op_name = cp->cpu_name; + op->op_name = ns(cp->cpu_name); op->op_value = 0; op->op_next = opt; opt = op; @@ -226,7 +231,6 @@ read_options() struct opt_list *po; int first = 1; char genopt[80]; - char *lower(); otab = 0; (void) snprintf(fname, sizeof fname, "../../conf/options"); @@ -298,7 +302,7 @@ read_options() goto next; } -char * +static char * lower(str) register char *str; { diff --git a/usr.sbin/config/mkswapconf.c b/usr.sbin/config/mkswapconf.c index 1d5756ff1ff2..18a80844915f 100644 --- a/usr.sbin/config/mkswapconf.c +++ b/usr.sbin/config/mkswapconf.c @@ -45,6 +45,9 @@ static char sccsid[] = "@(#)mkswapconf.c 8.1 (Berkeley) 6/6/93"; #include #include +#include + +#define ns(s) strdup(s) swapconf() {