Fixes for flaws found by gemini 3.8 on 21/10/26.

This commit is contained in:
unrealdragon 2026-10-21 21:59:19 +05:30
commit bc5760eee9

View file

@ -109,7 +109,7 @@ void printDefaults() {
std::cout << "StartUpRunner Default Values: " << std::endl;
std::cout << "Json file : " << options.json_file_path << std::endl;
std::cout << "Logs directory : " << options.log_directory << std::endl;
std::cout << "Log file max size: " << options.threads << std::endl;
std::cout << "Log file max size: " << options.log_file_max_size << std::endl;
std::cout << "Threads : " << options.threads << std::endl;
}
@ -189,7 +189,7 @@ Example startup_apps.json:
{
"name": "LS 2",
"app_name": "/bin/ls",
"app_arpgs": ["-lh"],
"app_args": ["-lh"],
"run_mode": "script",
"create_log": true,
"after": [{"module": "LS 0", "state": "exited"}],
@ -246,7 +246,7 @@ void parseArgs(int c, char *v[]) {
int i = contains(arg_list, "--json", "-j");
if(i >= 0) {
int j = i + 1;
if(j > arg_list.size()) {
if(j >= arg_list.size()) {
printHelp();
exit(-1);
}
@ -257,7 +257,7 @@ void parseArgs(int c, char *v[]) {
i = contains(arg_list, "--log_dir", "-ld");
if(i >= 0) {
int j = i + 1;
if(j > arg_list.size()) {
if(j >= arg_list.size()) {
printHelp();
exit(-1);
}
@ -268,7 +268,7 @@ void parseArgs(int c, char *v[]) {
i = contains(arg_list, "--threads", "-t");
if(i >= 0) {
int j = i + 1;
if(j > arg_list.size()) {
if(j >= arg_list.size()) {
printHelp();
exit(-1);
}
@ -278,29 +278,24 @@ void parseArgs(int c, char *v[]) {
}
i = contains(arg_list, "--test", "-T");
if(i >= 0) {
int j = i + 1;
if(j > arg_list.size()) {
printHelp();
exit(-1);
}
options.check_for_errors = true;
int j = i + 1;
if(j < arg_list.size() && arg_list[j].rfind("-", 0) != 0) {
options.json_file_path = arg_list[j];
}
std::cout << "Testing json file." << std::endl;
contains_any_known_arg = true;
}
i = contains(arg_list, "--help", "-h");
if(i >= 0) {
int j = i + 1;
if(j > arg_list.size()) {
printHelp();
exit(-1);
}
if(arg_list[j] == "json") {
if(j < arg_list.size() && arg_list[j] == "json") {
printJsonHelp();
exit(0);
}
else {
printHelp();
exit(-1);
exit(0);
}
contains_any_known_arg = true;
}
@ -339,11 +334,14 @@ std::vector<std::string> string_split(std::string s, const std::string& delimite
size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
tokens.push_back(token);
token = string_strip(s.substr(0, pos));
if(!token.empty())
tokens.push_back(token);
s.erase(0, pos + delimiter.length());
}
tokens.push_back(string_strip(s));
std::string last = string_strip(s);
if(!last.empty())
tokens.push_back(last);
return tokens;
}
@ -436,7 +434,7 @@ std::optional<int> checkAppList(std::deque<AppInfo::AppData> &copy_list, std::ve
}
}
if(!found) {
out << "Depenedency not found" << std::endl;
out << "Dependency not found" << std::endl;
}
}
after_list.push_back(std::move(app_info));
@ -463,19 +461,21 @@ std::optional<int> checkAppList(std::deque<AppInfo::AppData> &copy_list, std::ve
}
}
}
bool all_valid = true;
for(auto &i: after_list) {
bool run_validity = i->checkValidity();
i->printInfo(out);
for(auto &[j, state]: i->getParents()) {
if(state == AppInfo::State::exited && j->getRunMode() == AppInfo::RunMode::daemon) {
out << "[WARN]: " << i->getModuleName() <<
" is waiting for a daemon: " << j->getModuleName() << " to start exeuction." <<
" is waiting for a daemon: " << j->getModuleName() << " to start execution." <<
std::endl;
}
}
if(!run_validity) {
out << "[ERR]: " << i->getModuleName() <<
" incorrect format for scheduled run. Please see help page." << std::endl;
all_valid = false;
} else if((i->getScheduled()) && (!i->getRunOnStart())) {
const auto* zone = std::chrono::current_zone();
auto local_now = zone->to_local(i->getNextTimeToRun());
@ -491,9 +491,12 @@ std::optional<int> checkAppList(std::deque<AppInfo::AppData> &copy_list, std::ve
}
else {
out << "Module: " << i->getModuleName() <<
" is to be launched on init." << i->getScheduled() << i->getRunOnStart() << run_validity << std::endl;
" is to be launched on init." << std::endl;
}
}
if(!all_valid) {
return std::nullopt;
}
return 0;
}