X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=discover%2Fparser-conf.c;h=247e29d734fdea083ee508216271a6103b62b019;hb=e0040f05dd45c84214bfdef5d4c6eacf9586aa7b;hp=a21efc4aced845e10fec38469e9abcc72bc85ed9;hpb=60384121c27eb92c25955a06e8dea088290f938b;p=petitboot diff --git a/discover/parser-conf.c b/discover/parser-conf.c index a21efc4..247e29d 100644 --- a/discover/parser-conf.c +++ b/discover/parser-conf.c @@ -155,6 +155,9 @@ void conf_init_global_options(struct conf_context *conf) { int i; + if (!conf->global_options) + return; + for (i = 0; conf->global_options[i].name; i++) conf->global_options[i].value = NULL; } @@ -171,6 +174,8 @@ int conf_set_global_option(struct conf_context *conf, const char *name, { int i; + assert(conf->global_options); + for (i = 0; conf->global_options[i].name; i++) { if (streq(name, conf->global_options[i].name)) { conf->global_options[i].value @@ -196,6 +201,8 @@ const char *conf_get_global_option(struct conf_context *conf, { int i; + assert(conf->global_options); + for (i = 0; conf->global_options[i].name ;i++) if (streq(name, conf->global_options[i].name)) { pb_log("%s: @%s@%s@\n", __func__, name, @@ -217,8 +224,11 @@ static void conf_parse_buf(struct conf_context *conf) { char *pos, *name, *value; + assert(conf->get_pair); + assert(conf->process_pair); + for (pos = conf->buf; pos;) { - pos = conf_get_pair_equal(conf, pos, &name, &value, '\n'); + pos = conf->get_pair(conf, pos, &name, &value, '\n'); if (!value) continue; @@ -245,6 +255,7 @@ static void conf_parse_buf(struct conf_context *conf) int conf_parse(struct conf_context *conf) { + struct device *dev; int fd, rc; unsigned int i; struct stat stat; @@ -259,7 +270,7 @@ int conf_parse(struct conf_context *conf) for (i = 0; conf->conf_files[i]; i++) { char *filepath = resolve_path(conf->dc, - conf->conf_files[i], conf->dc->device_path); + conf->conf_files[i], conf->dc->device->device_path); pb_log("%s: try: %s\n", __func__, filepath); @@ -299,8 +310,9 @@ int conf_parse(struct conf_context *conf) if (len <= 0) goto out; - if (!conf->dc->device->icon_file) - conf->dc->device->icon_file = talloc_strdup(conf->dc, + dev = conf->dc->device->device; + if (!dev->icon_file) + dev->icon_file = talloc_strdup(dev, generic_icon_file(guess_device_type(conf->dc))); conf_parse_buf(conf);