boot/autodetect: Allow detecting root to be empty string

master
Perttu Ahola 2014-10-31 13:46:10 +02:00
parent 55b4a74a31
commit 1ca0551652
1 changed files with 9 additions and 7 deletions

View File

@ -133,9 +133,10 @@ static void set_default_subpaths(core::Config &config, const PathDefinition *def
}
}
// If not found, returns empty string and logs issues
static ss_ find_root(const sv_<ss_> &roots, const PathDefinition *defs,
const char *description, const core::Config &base_config)
// If not found, returns false and logs issues
static bool find_root(const sv_<ss_> &roots, const PathDefinition *defs,
const char *description, const core::Config &base_config,
ss_ &result)
{
log_d(MODULE, "Searching root: %s", description);
// Try to find root
@ -147,7 +148,8 @@ static ss_ find_root(const sv_<ss_> &roots, const PathDefinition *defs,
config.values = base_config.values;
if(check_paths(config, defs, false)){
log_d(MODULE, "-> Root [%s] matches (%s)", cs(root), description);
return root;
result = root;
return true;
}
}
// Not found; Log issues and return
@ -160,14 +162,14 @@ static ss_ find_root(const sv_<ss_> &roots, const PathDefinition *defs,
config.values = base_config.values;
check_paths(config, defs, true);
}
return "";
return false;
}
static bool detect_paths(core::Config &config, const sv_<ss_> &roots,
const PathDefinition *defs, const char *description)
{
ss_ root = find_root(roots, defs, description, config);
if(root.empty()){
ss_ root;
if(!find_root(roots, defs, description, config, root)){
log_w(MODULE, "Could not determine %s path (tried %s)",
description, cs(roots));
return false;