X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=90bd3697b9f0ae46b2af7fc63d34a6ec1a8e2262;hb=0871c3095151bce6a4031a2662aa51b7193b855c;hp=de632af36289a2a5da948bb0db5a312ab4a5b460;hpb=1545909dcb3ac618754486f4ccd4d8f237d64bb7;p=tinc diff --git a/src/conf.c b/src/conf.c index de632af3..90bd3697 100644 --- a/src/conf.c +++ b/src/conf.c @@ -38,7 +38,14 @@ splay_tree_t *config_tree = NULL; int pinginterval = 0; /* seconds between pings */ int pingtimeout = 0; /* seconds to wait for response */ -list_t *cmdline_conf = NULL; /* global/host configuration values given at the command line */ + +/* global/host configuration values given at the command line */ +list_t cmdline_conf = { + .head = NULL, + .tail = NULL, + .count = 0, + .delete = (list_action_t)free_config, +}; static int config_compare(const config_t *a, const config_t *b) { int result; @@ -203,7 +210,7 @@ static char *readline(FILE *fp, char *buf, size_t buflen) { return NULL; } - p = fgets(buf, buflen, fp); + p = fgets(buf, (int) buflen, fp); if(!p) { return NULL; @@ -227,7 +234,6 @@ static char *readline(FILE *fp, char *buf, size_t buflen) { config_t *parse_config_line(char *line, const char *fname, int lineno) { config_t *cfg; - int len; char *variable, *value, *eol; variable = value = line; @@ -237,7 +243,7 @@ config_t *parse_config_line(char *line, const char *fname, int lineno) { *eol = '\0'; } - len = strcspn(value, "\t ="); + size_t len = strcspn(value, "\t ="); value += len; value += strspn(value, "\t "); @@ -335,13 +341,9 @@ bool read_config_file(splay_tree_t *config_tree, const char *fname, bool verbose } void read_config_options(splay_tree_t *config_tree, const char *prefix) { - if(!cmdline_conf) { - return; - } - size_t prefix_len = prefix ? strlen(prefix) : 0; - for(const list_node_t *node = cmdline_conf->tail; node; node = node->prev) { + for(const list_node_t *node = cmdline_conf.tail; node; node = node->prev) { const config_t *cfg = node->data; config_t *new;