mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
do not throw dynamically allocated exceptions
This commit is contained in:
parent
15984f460c
commit
21e05c2aa7
7 changed files with 16 additions and 16 deletions
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
setp = CPU_ALLOC(num_cpus);
|
||||
if (!setp)
|
||||
throw new villas::RuntimeError("Failed to allocated memory");
|
||||
throw villas::RuntimeError("Failed to allocated memory");
|
||||
|
||||
zero();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ CpuSet::CpuSet(const std::string &str) :
|
|||
start = std::stoi(token, &endpos);
|
||||
|
||||
if (token.begin() + endpos != token.end())
|
||||
throw new std::invalid_argument("Not a valid CPU set");
|
||||
throw std::invalid_argument("Not a valid CPU set");
|
||||
|
||||
if (start < num_cpus)
|
||||
set(start);
|
||||
|
@ -72,14 +72,14 @@ CpuSet::CpuSet(const std::string &str) :
|
|||
start = std::stoi(token, &endpos);
|
||||
|
||||
if (token.begin() + endpos != token.begin() + sep)
|
||||
throw new std::invalid_argument("Not a valid CPU set");
|
||||
throw std::invalid_argument("Not a valid CPU set");
|
||||
|
||||
auto token2 = token.substr(endpos + 1);
|
||||
|
||||
end = std::stoi(token2, &endpos);
|
||||
|
||||
if (token2.begin() + endpos != token2.end())
|
||||
throw new std::invalid_argument("Not a valid CPU set");
|
||||
throw std::invalid_argument("Not a valid CPU set");
|
||||
|
||||
for (size_t i = start; i <= end && i < num_cpus; i++)
|
||||
set(i);
|
||||
|
|
|
@ -32,7 +32,7 @@ Version villas::kernel::getVersion()
|
|||
struct utsname uts;
|
||||
|
||||
if (uname(&uts) < 0)
|
||||
throw new SystemError("Failed to retrieve system identification");
|
||||
throw SystemError("Failed to retrieve system identification");
|
||||
|
||||
std::string rel = uts.release;
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ int lockMemory()
|
|||
#ifdef _POSIX_MEMLOCK
|
||||
ret = mlockall(MCL_CURRENT | MCL_FUTURE);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to lock memory");
|
||||
throw SystemError("Failed to lock memory");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -117,7 +117,7 @@ int setAffinity(int affinity)
|
|||
|
||||
ret = sched_setaffinity(0, cset_pin.size(), cset_pin);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to set CPU affinity to {}", (std::string) cset_pin);
|
||||
throw SystemError("Failed to set CPU affinity to {}", (std::string) cset_pin);
|
||||
|
||||
logger->debug("Set affinity to {}", (std::string) cset_pin);
|
||||
|
||||
|
@ -133,7 +133,7 @@ int setPriority(int priority)
|
|||
|
||||
ret = sched_setscheduler(0, SCHED_FIFO, ¶m);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to set real time priority");
|
||||
throw SystemError("Failed to set real time priority");
|
||||
|
||||
logger->debug("Task priority set to {}", priority);
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ void Log::parse(json_t *cfg)
|
|||
"pattern", &pattern
|
||||
);
|
||||
if (ret)
|
||||
throw new JsonError(err);
|
||||
throw JsonError(err);
|
||||
|
||||
if (level)
|
||||
setLevel(level);
|
||||
|
@ -109,7 +109,7 @@ void Log::parse(json_t *cfg)
|
|||
|
||||
if (json_expressions) {
|
||||
if (!json_is_array(json_expressions))
|
||||
throw new ConfigError(json_expressions, "node-config.html#node-config-logging-expressions", "The 'expressions' setting must be a list of objects.");
|
||||
throw ConfigError(json_expressions, "node-config.html#node-config-logging-expressions", "The 'expressions' setting must be a list of objects.");
|
||||
|
||||
size_t i;
|
||||
json_t *json_expression;
|
||||
|
@ -122,7 +122,7 @@ void Log::parse(json_t *cfg)
|
|||
"level", &lvl
|
||||
);
|
||||
if (ret)
|
||||
throw new JsonError(err);
|
||||
throw JsonError(err);
|
||||
|
||||
Logger logger = get(name);
|
||||
auto level = spdlog::level::from_str(lvl);
|
||||
|
|
|
@ -45,12 +45,12 @@ Terminal::Terminal()
|
|||
|
||||
ret = sigaction(SIGWINCH, &sa_resize, NULL);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to register signal handler");
|
||||
throw SystemError("Failed to register signal handler");
|
||||
|
||||
/* Try to get initial terminal dimensions */
|
||||
ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to get terminal dimensions");
|
||||
throw SystemError("Failed to get terminal dimensions");
|
||||
}
|
||||
|
||||
/* Fallback if for some reason we can not determine a prober window size */
|
||||
|
@ -67,7 +67,7 @@ void Terminal::resize(int, siginfo_t *, void *)
|
|||
|
||||
ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to get terminal dimensions");
|
||||
throw SystemError("Failed to get terminal dimensions");
|
||||
|
||||
Logger logger = logging.get("terminal");
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ Version::Version(const std::string &str)
|
|||
auto comp = tokenize(str, ".");
|
||||
|
||||
if (comp.size() > 3)
|
||||
throw new std::invalid_argument("Not a valid version string");
|
||||
throw std::invalid_argument("Not a valid version string");
|
||||
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
if (i < comp.size()) {
|
||||
components[i] = std::stoi(comp[i], &endpos, 10);
|
||||
|
||||
if (comp[i].begin() + endpos != comp[i].end())
|
||||
throw new std::invalid_argument("Not a valid version string");
|
||||
throw std::invalid_argument("Not a valid version string");
|
||||
}
|
||||
else
|
||||
components[i] = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue