From 3fe3a9def1288d9f68cbce7d8a34bca05b1e0b01 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 26 Aug 2022 11:16:07 +0200 Subject: [PATCH] Use "std::vector" instead of C-style array (sonar). --- src/mc/api/RemoteApp.cpp | 7 ++++--- src/mc/remote/AppSide.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mc/api/RemoteApp.cpp b/src/mc/api/RemoteApp.cpp index 6cf19b0a42..cc4cea60d2 100644 --- a/src/mc/api/RemoteApp.cpp +++ b/src/mc/api/RemoteApp.cpp @@ -165,10 +165,11 @@ void RemoteApp::get_actors_status(std::map& whereto) const to_c_str(answer.type), (int)answer.type, (int)received, (int)MessageType::ACTORS_STATUS_REPLY, (int)sizeof(answer)); - s_mc_message_actors_status_one_t status[answer.count]; + std::vector status(answer.count); if (answer.count > 0) { - received = model_checker_->channel().receive(&status, sizeof(status)); - xbt_assert(static_cast(received) == sizeof(status)); + size_t size = status.size() * sizeof(s_mc_message_actors_status_one_t); + received = model_checker_->channel().receive(status.data(), size); + xbt_assert(static_cast(received) == size); } whereto.clear(); diff --git a/src/mc/remote/AppSide.cpp b/src/mc/remote/AppSide.cpp index 690d190147..e74e4d4f13 100644 --- a/src/mc/remote/AppSide.cpp +++ b/src/mc/remote/AppSide.cpp @@ -149,7 +149,7 @@ void AppSide::handle_actors_status() const struct s_mc_message_actors_status_answer_t answer { MessageType::ACTORS_STATUS_REPLY, count }; - s_mc_message_actors_status_one_t status[count]; + std::vector status(count); int i = 0; for (auto const& [aid, actor] : actor_list) { status[i].aid = aid; @@ -158,8 +158,10 @@ void AppSide::handle_actors_status() const i++; } xbt_assert(channel_.send(answer) == 0, "Could not send ACTORS_STATUS_REPLY msg"); - if (answer.count > 0) - xbt_assert(channel_.send(status, sizeof(status)) == 0, "Could not send ACTORS_STATUS_REPLY data"); + if (answer.count > 0) { + size_t size = status.size() * sizeof(s_mc_message_actors_status_one_t); + xbt_assert(channel_.send(status.data(), size) == 0, "Could not send ACTORS_STATUS_REPLY data"); + } } #define assert_msg_size(_name_, _type_) \ -- 2.20.1