Commit c77e337a authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

do not throw dynamically allocated exceptions

parent 4dfbf8bc
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
setp = CPU_ALLOC(num_cpus); setp = CPU_ALLOC(num_cpus);
if (!setp) if (!setp)
throw new villas::RuntimeError("Failed to allocated memory"); throw villas::RuntimeError("Failed to allocated memory");
zero(); zero();
} }
......
...@@ -63,7 +63,7 @@ CpuSet::CpuSet(const std::string &str) : ...@@ -63,7 +63,7 @@ CpuSet::CpuSet(const std::string &str) :
start = std::stoi(token, &endpos); start = std::stoi(token, &endpos);
if (token.begin() + endpos != token.end()) 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) if (start < num_cpus)
set(start); set(start);
...@@ -72,14 +72,14 @@ CpuSet::CpuSet(const std::string &str) : ...@@ -72,14 +72,14 @@ CpuSet::CpuSet(const std::string &str) :
start = std::stoi(token, &endpos); start = std::stoi(token, &endpos);
if (token.begin() + endpos != token.begin() + sep) 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); auto token2 = token.substr(endpos + 1);
end = std::stoi(token2, &endpos); end = std::stoi(token2, &endpos);
if (token2.begin() + endpos != token2.end()) 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++) for (size_t i = start; i <= end && i < num_cpus; i++)
set(i); set(i);
......
...@@ -32,7 +32,7 @@ Version villas::kernel::getVersion() ...@@ -32,7 +32,7 @@ Version villas::kernel::getVersion()
struct utsname uts; struct utsname uts;
if (uname(&uts) < 0) if (uname(&uts) < 0)
throw new SystemError("Failed to retrieve system identification"); throw SystemError("Failed to retrieve system identification");
std::string rel = uts.release; std::string rel = uts.release;
......
...@@ -85,7 +85,7 @@ int lockMemory() ...@@ -85,7 +85,7 @@ int lockMemory()
#ifdef _POSIX_MEMLOCK #ifdef _POSIX_MEMLOCK
ret = mlockall(MCL_CURRENT | MCL_FUTURE); ret = mlockall(MCL_CURRENT | MCL_FUTURE);
if (ret) if (ret)
throw new SystemError("Failed to lock memory"); throw SystemError("Failed to lock memory");
#endif #endif
return 0; return 0;
...@@ -117,7 +117,7 @@ int setAffinity(int affinity) ...@@ -117,7 +117,7 @@ int setAffinity(int affinity)
ret = sched_setaffinity(0, cset_pin.size(), cset_pin); ret = sched_setaffinity(0, cset_pin.size(), cset_pin);
if (ret) 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); logger->debug("Set affinity to {}", (std::string) cset_pin);
...@@ -133,7 +133,7 @@ int setPriority(int priority) ...@@ -133,7 +133,7 @@ int setPriority(int priority)
ret = sched_setscheduler(0, SCHED_FIFO, &param); ret = sched_setscheduler(0, SCHED_FIFO, &param);
if (ret) 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); logger->debug("Task priority set to {}", priority);
......
...@@ -90,7 +90,7 @@ void Log::parse(json_t *cfg) ...@@ -90,7 +90,7 @@ void Log::parse(json_t *cfg)
"pattern", &pattern "pattern", &pattern
); );
if (ret) if (ret)
throw new JsonError(err); throw JsonError(err);
if (level) if (level)
setLevel(level); setLevel(level);
...@@ -109,7 +109,7 @@ void Log::parse(json_t *cfg) ...@@ -109,7 +109,7 @@ void Log::parse(json_t *cfg)
if (json_expressions) { if (json_expressions) {
if (!json_is_array(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; size_t i;
json_t *json_expression; json_t *json_expression;
...@@ -122,7 +122,7 @@ void Log::parse(json_t *cfg) ...@@ -122,7 +122,7 @@ void Log::parse(json_t *cfg)
"level", &lvl "level", &lvl
); );
if (ret) if (ret)
throw new JsonError(err); throw JsonError(err);
Logger logger = get(name); Logger logger = get(name);
auto level = spdlog::level::from_str(lvl); auto level = spdlog::level::from_str(lvl);
......
...@@ -45,12 +45,12 @@ Terminal::Terminal() ...@@ -45,12 +45,12 @@ Terminal::Terminal()
ret = sigaction(SIGWINCH, &sa_resize, NULL); ret = sigaction(SIGWINCH, &sa_resize, NULL);
if (ret) if (ret)
throw new SystemError("Failed to register signal handler"); throw SystemError("Failed to register signal handler");
/* Try to get initial terminal dimensions */ /* Try to get initial terminal dimensions */
ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window); ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
if (ret) 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 */ /* Fallback if for some reason we can not determine a prober window size */
...@@ -67,7 +67,7 @@ void Terminal::resize(int, siginfo_t *, void *) ...@@ -67,7 +67,7 @@ void Terminal::resize(int, siginfo_t *, void *)
ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window); ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
if (ret) if (ret)
throw new SystemError("Failed to get terminal dimensions"); throw SystemError("Failed to get terminal dimensions");
Logger logger = logging.get("terminal"); Logger logger = logging.get("terminal");
......
...@@ -36,14 +36,14 @@ Version::Version(const std::string &str) ...@@ -36,14 +36,14 @@ Version::Version(const std::string &str)
auto comp = tokenize(str, "."); auto comp = tokenize(str, ".");
if (comp.size() > 3) 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++) { for (unsigned i = 0; i < 3; i++) {
if (i < comp.size()) { if (i < comp.size()) {
components[i] = std::stoi(comp[i], &endpos, 10); components[i] = std::stoi(comp[i], &endpos, 10);
if (comp[i].begin() + endpos != comp[i].end()) 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 else
components[i] = 0; components[i] = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment