summaryrefslogtreecommitdiff
path: root/sbin/dhclient/clparse.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2019-01-14 04:05:43 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2019-01-14 04:05:43 +0000
commit6ca3de237184ec8f8cc312fec804310efd1a381c (patch)
tree595c64819c6be0dbc8f19e432b86e4e91e9643c5 /sbin/dhclient/clparse.c
parent65b166d4d88387ba454e5b37046e5f20cc6ce766 (diff)
Abstract allocation and initialization of config global
variable into init_config() and just call it from read_conf().
Diffstat (limited to 'sbin/dhclient/clparse.c')
-rw-r--r--sbin/dhclient/clparse.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 831c5c6c513..ee70cc4ab80 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.174 2019/01/14 03:05:33 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.175 2019/01/14 04:05:42 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -76,21 +76,15 @@ void parse_lease_decl(FILE *, struct client_lease *, char *);
int parse_option(FILE *, int *, struct option_data *);
int parse_reject_statement(FILE *);
-/*
- * conf-decls :==
- * <nil>
- * | conf-decl
- * | conf-decls conf-decl
- */
void
-read_conf(char *name)
+init_config(void)
{
struct option_data *option;
- FILE *cfile;
- int token;
uint32_t expiry;
- new_parse(path_dhclient_conf);
+ config = calloc(1, sizeof(*config));
+ if (config == NULL)
+ fatal("config");
TAILQ_INIT(&config->reject_list);
@@ -144,6 +138,23 @@ read_conf(char *name)
[config->requested_option_count++] = DHO_BOOTFILE_NAME;
config->requested_options
[config->requested_option_count++] = DHO_TFTP_SERVER;
+}
+
+/*
+ * conf-decls :==
+ * <nil>
+ * | conf-decl
+ * | conf-decls conf-decl
+ */
+void
+read_conf(char *name)
+{
+ FILE *cfile;
+ int token;
+
+ init_config();
+
+ new_parse(path_dhclient_conf);
if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) {
for (;;) {