On Sun, Aug 13, 2017 at 01:45:48PM +0200, Eric Faurot wrote: > Remove the table_static_parse() indirection for parsing the file content. > The "type" parameter is useless since the "(t->t_type & type)" test is always > true. I think this is a left-over from the old design when table parsing was > done in context of its intended use in the global config. >
this is a leftover from when tables were called maps and used to be declared with a type ok gilles@ > Index: table_static.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/table_static.c,v > retrieving revision 1.15 > diff -u -p -r1.15 table_static.c > --- table_static.c 22 Jan 2016 13:08:44 -0000 1.15 > +++ table_static.c 13 Aug 2017 11:28:50 -0000 > @@ -47,7 +47,6 @@ static int table_static_lookup(void *, s > static int table_static_fetch(void *, struct dict *, enum table_service, > union lookup *); > static void table_static_close(void *); > -static int table_static_parse(struct table *, const char *, enum table_type); > > struct table_backend table_backend_static = { > K_ALIAS|K_CREDENTIALS|K_DOMAIN|K_NETADDR|K_USERINFO| > @@ -71,17 +70,7 @@ static struct keycmp { > > > static int > -table_static_config(struct table *table) > -{ > - /* no config ? ok */ > - if (*table->t_config == '\0') > - return 1; > - > - return table_static_parse(table, table->t_config, T_LIST|T_HASH); > -} > - > -static int > -table_static_parse(struct table *t, const char *config, enum table_type type) > +table_static_config(struct table *t) > { > FILE *fp; > char *buf = NULL; > @@ -91,10 +80,14 @@ table_static_parse(struct table *t, cons > char *valp; > size_t ret = 0; > > - if ((fp = fopen(config, "r")) == NULL) { > - log_warn("warn: Table \"%s\"", config); > - return 0; > - } > + /* no config ? ok */ > + if (*t->t_config == '\0') > + return 1; > + > + if ((fp = fopen(t->t_config, "r")) == NULL) { > + log_warn("warn: Table \"%s\"", t->t_config); > + return 0; > + } > > while ((flen = getline(&buf, &sz, fp)) != -1) { > if (buf[flen - 1] == '\n') > @@ -122,9 +115,6 @@ table_static_parse(struct table *t, cons > if (t->t_type == 0) > t->t_type = (valp == keyp || valp == NULL) ? T_LIST : > T_HASH; > - > - if (!(t->t_type & type)) > - goto end; > > if ((valp == keyp || valp == NULL) && t->t_type == T_LIST) > table_add(t, keyp, NULL); > -- Gilles Chehade https://www.poolp.org @poolpOrg