Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions resource-tuner/init/RestuneInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,9 @@ static ErrCode init(void* arg) {
UrmSettings::metaConfigs.mPluginCount = (uint32_t)std::stol(resultBuffer);

uint32_t pluginCount = UrmSettings::metaConfigs.mPluginCount;
if(pluginCount > MAX_EXTENSION_LIB_HANDLES) {
extensionLibHandles = (void**) malloc(pluginCount * sizeof(void*));
if(extensionLibHandles == nullptr) {
return RC_MODULE_INIT_FAILURE;
}
extensionLibHandles = (void**) calloc(pluginCount, sizeof(void*));
if(extensionLibHandles == nullptr) {
return RC_MODULE_INIT_FAILURE;
}

if(RC_IS_NOTOK(fetchMetaConfigs())) {
Expand Down
60 changes: 60 additions & 0 deletions resource-tuner/init/RestuneParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,67 @@ static int8_t isKeyTypeList(const std::string& keyName) {
return false;
}

static int32_t onDeviceNodesCount(const std::string& filePath) {
SETUP_LIBYAML_PARSING(filePath);

int8_t parsingDone = false;
int8_t docMarker = false;
int8_t parsingKey = false;
int32_t count = 0;

std::string value = "";

while(!parsingDone) {
if(!yaml_parser_parse(&parser, &event)) {
return RC_YAML_PARSING_ERROR;
}

switch(event.type) {
case YAML_STREAM_END_EVENT:
parsingDone = true;
break;

case YAML_MAPPING_START_EVENT:
if(!docMarker) {
docMarker = true;
}
break;

case YAML_SCALAR_EVENT:
if(event.data.scalar.value != nullptr) {
value = reinterpret_cast<char*>(event.data.scalar.value);
}

if(value == RESOURCE_CONFIGS_ELEM_RESOURCEPATH) {
parsingKey = true;
} else {
if(parsingKey) {
if(AuxRoutines::fileExists(value)) {
count++;
}
}
parsingKey = false;
}

break;

default:
break;
}

yaml_event_delete(&event);
}

TEARDOWN_LIBYAML_PARSING
return count;
}

ErrCode RestuneParser::parseResourceConfigYamlNode(const std::string& filePath) {
if(onDeviceNodesCount(filePath) == 0) {
// None of the nodes exsit, no need to parse these configs
return RC_SUCCESS;
}

SETUP_LIBYAML_PARSING(filePath);

ErrCode rc = RC_SUCCESS;
Expand Down