From 167580ed173f1267354e8e1962a77149e760dcc2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 21 Jun 2016 01:11:30 +0200 Subject: [PATCH] small improvments advised by sonar --- include/simgrid/kernel/future.hpp | 8 +++++--- src/xbt/xbt_replay.cpp | 7 +++++-- src/xbt/xbt_str.cpp | 9 ++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index ffd1a33e29..9b6a5fc88b 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -70,6 +70,8 @@ public: // executing it later: continuation_ = std::move(continuation); break; + default: + DIE_IMPOSSIBLE; } } @@ -84,8 +86,8 @@ public: } protected: - FutureStateBase() {} - ~FutureStateBase() {}; + FutureStateBase() = default; + ~FutureStateBase() = default; /** Set the future as ready and trigger the continuation */ void set_ready() @@ -252,7 +254,7 @@ public: template class Future { public: - Future() {} + Future() = default; Future(std::shared_ptr> state): state_(std::move(state)) {} // Move type: diff --git a/src/xbt/xbt_replay.cpp b/src/xbt/xbt_replay.cpp index d9e475b8de..705cd0fce0 100644 --- a/src/xbt/xbt_replay.cpp +++ b/src/xbt/xbt_replay.cpp @@ -148,8 +148,11 @@ int xbt_replay_action_runner(int argc, char *argv[]) { int i; if (xbt_action_fp) { // A unique trace file - char **evt; - while ((evt = action_get_action(argv[0]))) { + while (true) { + char **evt = action_get_action(argv[0]); + if (evt == nullptr) + break; + char* lowername = str_tolower (evt[1]); action_fun function = (action_fun)xbt_dict_get(xbt_action_funs, lowername); xbt_free(lowername); diff --git a/src/xbt/xbt_str.cpp b/src/xbt/xbt_str.cpp index 9f817dc977..fb38748d24 100644 --- a/src/xbt/xbt_str.cpp +++ b/src/xbt/xbt_str.cpp @@ -199,7 +199,8 @@ xbt_dynar_t xbt_str_split(const char *s, const char *sep) is_sep[0] = 1; /* End of string is also separator */ /* Do the job */ - p = q = s; + p = s; + q = s; done = 0; if (s[0] == '\0') @@ -234,7 +235,8 @@ xbt_dynar_t xbt_str_split_str(const char *s, const char *sep) int done; const char *p, *q; - p = q = s; + p = s; + q = s; done = 0; if (s[0] == '\0') @@ -446,7 +448,8 @@ char *xbt_str_join_array(const char *const *strs, const char *sep) len += strlen(sep) * amount_strings; /* Do the job */ - q = res = (char*) xbt_malloc(len); + res = (char*) xbt_malloc(len); + q = res; for (i=0;strs[i];i++) { if (i!=0) { // not first loop q += snprintf(q,len, "%s%s", sep, strs[i]); -- 2.20.1