On Tue, Nov 26, 2019 at 12:59:31PM -0600, Matthew Martin wrote: > Another option would be to pass NULL for the default config which avoids > adding another parameter. Something like the below diff. Fine with me; I briefly tried using NULL but did not get it right since I always set filename before parse_config(), leaving no way inside this function to distinguish between filename having implicitly defaulted or being set to /etc/unwind.conf explicitly.
Thanks for the diff, I'll ammend my last commit to match yours. > diff --git parse.y parse.y > index a26f46e6c08..c4d6298aa01 100644 > --- parse.y > +++ parse.y > @@ -782,9 +782,9 @@ parse_config(char *filename) > > conf = config_new_empty(); > > - file = pushfile(filename, 0); > + file = pushfile(filename != NULL ? filename : CONF_FILE, 0); > if (file == NULL) { > - if (errno == ENOENT) /* no config file is fine */ > + if (errno == ENOENT && filename == NULL) /* no config > file is fine */ That line is too long, I'll also update the comment - if (errno == ENOENT) /* no config file is fine */ + /* no default config file is fine */ + if (errno == ENOENT && filename == NULL) > return (conf); > log_warn("%s", filename); > free(conf); > diff --git unwind.c unwind.c > index 87e3fa87ac3..1fa08353b3c 100644 > --- unwind.c > +++ unwind.c > @@ -132,7 +132,7 @@ main(int argc, char *argv[]) > int control_fd, ta_fd; > char *csock, *saved_argv0; > > - conffile = CONF_FILE; > + conffile = NULL; conffile is a global static so it's NULL initialised already, I'd just remove that line. > csock = UNWIND_SOCKET; > > log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */