From 4b90ce2abff77ca7898fd9292a122440df739916 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 2 Jul 2020 22:16:06 +0200 Subject: [PATCH] [sonar] Convert integer literals to bool literals. --- .../s4u-mc-bugged1-liveness.cpp | 4 +- .../s4u-platform-failures.cpp | 2 +- src/include/xbt/parmap.hpp | 2 +- src/kernel/activity/CommImpl.cpp | 2 +- src/kernel/routing/DijkstraZone.cpp | 6 ++- src/kernel/routing/FloydZone.cpp | 4 +- .../CommunicationDeterminismChecker.cpp | 4 +- src/mc/inspect/LocationList.cpp | 2 +- src/mc/remote/AppSide.cpp | 4 +- src/mc/remote/RemoteSimulation.cpp | 2 +- src/mc/sosp/Snapshot.cpp | 2 +- src/plugins/host_dvfs.cpp | 2 +- src/simdag/sd_task.cpp | 2 +- src/simix/libsmx.cpp | 4 +- src/simix/popping_bodies.cpp | 38 +++++++++---------- src/simix/popping_private.hpp | 4 +- src/simix/simcalls.py | 2 +- src/smpi/internals/smpi_deployment.cpp | 2 +- src/smpi/mpi/smpi_comm.cpp | 6 +-- src/surf/ptask_L07.cpp | 2 +- src/surf/surf_c_bindings.cpp | 2 +- src/xbt/log.cpp | 4 +- src/xbt/xbt_log_layout_format.cpp | 36 +++++++++--------- teshsuite/s4u/host-on-off/host-on-off.cpp | 2 +- .../storage_client_server.cpp | 2 +- 25 files changed, 73 insertions(+), 69 deletions(-) diff --git a/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp b/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp index ef3b97998a..286b06ed92 100644 --- a/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp +++ b/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp @@ -52,7 +52,7 @@ static void coordinator() simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("coordinator"); - while (1) { + while (true) { m = static_cast(mbox->get()); if (m->kind == Message::Kind::REQUEST) { if (CS_used) { @@ -91,7 +91,7 @@ static void client(int id) simgrid::s4u::Mailbox* my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id)); - while (1) { + while (true) { XBT_INFO("Ask the request"); simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000); diff --git a/examples/s4u/platform-failures/s4u-platform-failures.cpp b/examples/s4u/platform-failures/s4u-platform-failures.cpp index a8104a5deb..b265c581a6 100644 --- a/examples/s4u/platform-failures/s4u-platform-failures.cpp +++ b/examples/s4u/platform-failures/s4u-platform-failures.cpp @@ -74,7 +74,7 @@ static void worker(int argc, char* argv[]) xbt_assert(argc == 2, "Expecting one parameter"); long id = xbt_str_parse_int(argv[1], "Invalid argument %s"); simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id)); - while (1) { + while (true) { try { XBT_INFO("Waiting a message on %s", mailbox->get_cname()); const double* payload = static_cast(mailbox->get()); diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index 58b59cd8ea..295ad660f6 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -294,7 +294,7 @@ template void Parmap::worker_main(ThreadData* data) XBT_CDEBUG(xbt_parmap, "New worker thread created"); /* Worker's main loop */ - while (1) { + while (true) { round++; // New scheduling round parmap.synchro->worker_wait(round); if (parmap.destroying) diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index d5c1ff3884..63cb6a505a 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -25,7 +25,7 @@ XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sr void* data, double timeout) { simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_isend( - simcall, src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0); + simcall, src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, false); SIMCALL_SET_MC_VALUE(*simcall, 0); simcall_HANDLER_comm_wait(simcall, static_cast(comm.get()), timeout); } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index d5c854f40c..bb780822b1 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -227,10 +227,12 @@ void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, Net { add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical); - new_edge(src->id(), dst->id(), new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 1)); + new_edge(src->id(), dst->id(), + new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, true)); if (symmetrical == true) - new_edge(dst->id(), src->id(), new_extended_route(hierarchy_, dst, src, gw_dst, gw_src, link_list, symmetrical, 0)); + new_edge(dst->id(), src->id(), + new_extended_route(hierarchy_, dst, src, gw_dst, gw_src, link_list, symmetrical, false)); } void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route) diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index bdae1de452..7bfd8ba334 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -118,7 +118,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi dst->get_cname()); TO_FLOYD_LINK(src->id(), dst->id()) = - new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 1); + new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, true); TO_FLOYD_PRED(src->id(), dst->id()) = src->id(); TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list.size(); @@ -146,7 +146,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi src->get_cname(), gw_dst->get_cname()); TO_FLOYD_LINK(dst->id(), src->id()) = - new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 0); + new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, false); TO_FLOYD_PRED(dst->id(), src->id()) = dst->id(); TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list.size(); /* count of links, old model assume 1 */ diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 37acf2e629..89f2249a8d 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -127,12 +127,12 @@ void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, co if (diff != NONE_DIFF) { if (comm->type == PatternCommunicationType::send) { - this->send_deterministic = 0; + this->send_deterministic = false; if (this->send_diff != nullptr) xbt_free(this->send_diff); this->send_diff = print_determinism_result(diff, process, comm, list.index_comm + 1); } else { - this->recv_deterministic = 0; + this->recv_deterministic = false; if (this->recv_diff != nullptr) xbt_free(this->recv_diff); this->recv_diff = print_determinism_result(diff, process, comm, list.index_comm + 1); diff --git a/src/mc/inspect/LocationList.cpp b/src/mc/inspect/LocationList.cpp index 276ce897db..07c7c3d002 100644 --- a/src/mc/inspect/LocationList.cpp +++ b/src/mc/inspect/LocationList.cpp @@ -65,7 +65,7 @@ LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Att { LocationList locations; std::ptrdiff_t offset = 0; - while (1) { + while (true) { Dwarf_Addr base; Dwarf_Addr start; Dwarf_Addr end; diff --git a/src/mc/remote/AppSide.cpp b/src/mc/remote/AppSide.cpp index 0c7ff0d0b2..486a9c79fd 100644 --- a/src/mc/remote/AppSide.cpp +++ b/src/mc/remote/AppSide.cpp @@ -108,7 +108,7 @@ void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) cons void AppSide::handle_messages() { - while (1) { + while (true) { XBT_DEBUG("Waiting messages from model-checker"); char message_buffer[MC_MESSAGE_LENGTH]; @@ -147,7 +147,7 @@ void AppSide::handle_messages() void AppSide::main_loop() { - while (1) { + while (true) { simgrid::mc::wait_for_requests(); xbt_assert(channel_.send(MC_MESSAGE_WAITING) == 0, "Could not send WAITING message to model-checker"); this->handle_messages(); diff --git a/src/mc/remote/RemoteSimulation.cpp b/src/mc/remote/RemoteSimulation.cpp index 34d1f27f80..a293fb5d3e 100644 --- a/src/mc/remote/RemoteSimulation.cpp +++ b/src/mc/remote/RemoteSimulation.cpp @@ -424,7 +424,7 @@ std::string RemoteSimulation::read_string(RemotePtr address) const std::vector res(128); off_t off = 0; - while (1) { + while (true) { ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t)address.address() + off); if (c == -1 && errno == EINTR) continue; diff --git a/src/mc/sosp/Snapshot.cpp b/src/mc/sosp/Snapshot.cpp index 7e799892f4..ccc1ac9728 100644 --- a/src/mc/sosp/Snapshot.cpp +++ b/src/mc/sosp/Snapshot.cpp @@ -104,7 +104,7 @@ static std::vector unwind_stack_frames(UnwindContext* stack_ // TODO, check condition check (unw_init_local==0 means end of frame) - while (1) { + while (true) { s_mc_stack_frame_t stack_frame; stack_frame.unw_cursor = c; diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index b46ed2d000..8082018af3 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -414,7 +414,7 @@ static void on_host_added(simgrid::s4u::Host& host) } }(); - while (1) { + while (true) { // Sleep *before* updating; important for startup (i.e., t = 0). // In the beginning, we want to go with the pstates specified in the platform file // (so we sleep first) diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index 4bde0b8dc3..ec33841917 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -40,7 +40,7 @@ SD_task_t SD_task_create(const char *name, void *data, double amount) task->state= SD_NOT_SCHEDULED; sd_global->initial_tasks.insert(task); - task->marked = 0; + task->marked = false; task->start_time = -1.0; task->finish_time = -1.0; task->surf_action = nullptr; diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 5830d3254e..86e74dac3b 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -97,8 +97,8 @@ void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, /* the model-checker wants two separate simcalls */ simgrid::kernel::activity::ActivityImplPtr comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */ - comm = simcall_comm_isend(sender, mbox, task_size, rate, - src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0); + comm = simcall_comm_isend(sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, + data, false); simcall_comm_wait(comm.get(), timeout); comm = nullptr; } diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index d284a1603c..c659920331 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -41,133 +41,133 @@ inline static R simcall(e_smx_simcall_t call, T const&... t) inline static int simcall_BODY_execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_execution_waitany_for(&SIMIX_process_self()->simcall_, execs, count, timeout); return simcall(SIMCALL_EXECUTION_WAITANY_FOR, execs, count, timeout); } inline static void simcall_BODY_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_send(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout); return simcall(SIMCALL_COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout); } inline static boost::intrusive_ptr simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached); return simcall, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached); } inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_recv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate); return simcall(SIMCALL_COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate); } inline static boost::intrusive_ptr simcall_BODY_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_irecv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); return simcall, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_IRECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); } inline static int simcall_BODY_comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall_, comms, count, timeout); return simcall(SIMCALL_COMM_WAITANY, comms, count, timeout); } inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_wait(&SIMIX_process_self()->simcall_, comm, timeout); return simcall(SIMCALL_COMM_WAIT, comm, timeout); } inline static bool simcall_BODY_comm_test(simgrid::kernel::activity::CommImpl* comm) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_test(&SIMIX_process_self()->simcall_, comm); return simcall(SIMCALL_COMM_TEST, comm); } inline static int simcall_BODY_comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_testany(&SIMIX_process_self()->simcall_, comms, count); return simcall(SIMCALL_COMM_TESTANY, comms, count); } inline static void simcall_BODY_mutex_lock(smx_mutex_t mutex) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_mutex_lock(&SIMIX_process_self()->simcall_, mutex); return simcall(SIMCALL_MUTEX_LOCK, mutex); } inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_mutex_trylock(&SIMIX_process_self()->simcall_, mutex); return simcall(SIMCALL_MUTEX_TRYLOCK, mutex); } inline static void simcall_BODY_mutex_unlock(smx_mutex_t mutex) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_mutex_unlock(&SIMIX_process_self()->simcall_, mutex); return simcall(SIMCALL_MUTEX_UNLOCK, mutex); } inline static void simcall_BODY_cond_wait(smx_cond_t cond, smx_mutex_t mutex) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_cond_wait(&SIMIX_process_self()->simcall_, cond, mutex); return simcall(SIMCALL_COND_WAIT, cond, mutex); } inline static int simcall_BODY_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_cond_wait_timeout(&SIMIX_process_self()->simcall_, cond, mutex, timeout); return simcall(SIMCALL_COND_WAIT_TIMEOUT, cond, mutex, timeout); } inline static void simcall_BODY_sem_acquire(smx_sem_t sem) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_sem_acquire(&SIMIX_process_self()->simcall_, sem); return simcall(SIMCALL_SEM_ACQUIRE, sem); } inline static int simcall_BODY_sem_acquire_timeout(smx_sem_t sem, double timeout) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_sem_acquire_timeout(&SIMIX_process_self()->simcall_, sem, timeout); return simcall(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout); } inline static int simcall_BODY_mc_random(int min, int max) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall_, min, max); return simcall(SIMCALL_MC_RANDOM, min, max); } inline static void simcall_BODY_run_kernel(std::function const* code) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ SIMIX_run_kernel(code); return simcall const*>(SIMCALL_RUN_KERNEL, code); } inline static void simcall_BODY_run_blocking(std::function const* code) { - if (0) /* Go to that function to follow the code flow through the simcall barrier */ + if (false) /* Go to that function to follow the code flow through the simcall barrier */ SIMIX_run_blocking(code); return simcall const*>(SIMCALL_RUN_BLOCKING, code); } diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index 70e6d28f92..83e7c00935 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -48,8 +48,8 @@ struct s_smx_simcall { smx_timer_t timeout_cb_ = nullptr; // Callback to timeouts simgrid::mc::SimcallInspector* inspector_ = nullptr; // makes that simcall observable by the MC int mc_value_ = 0; - u_smx_scalar args_[11] = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}}; - u_smx_scalar result_ = {0}; + u_smx_scalar args_[11] = {}; + u_smx_scalar result_ = {}; }; #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall).mc_value_ = (value)) diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 80845dabaf..5b0f872197 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -156,7 +156,7 @@ class Simcall(object): self.name, ', '.join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))) res.append('{') - res.append(' if (0) /* Go to that function to follow the code flow through the simcall barrier */') + res.append(' if (false) /* Go to that function to follow the code flow through the simcall barrier */') if self.need_handler: res.append(' simcall_HANDLER_%s(%s);' % (self.name, ', '.join(["&SIMIX_process_self()->simcall_"] + [arg.name for arg in self.args]))) diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index 7d3d3872a8..6eb504a9be 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -23,7 +23,7 @@ public: Instance(int max_no_processes, MPI_Comm comm) : size_(max_no_processes), comm_world_(comm) { MPI_Group group = new simgrid::smpi::Group(size_); - comm_world_ = new simgrid::smpi::Comm(group, nullptr, 0, -1); + comm_world_ = new simgrid::smpi::Comm(group, nullptr, false, -1); // FIXME : using MPI_Attr_put with MPI_UNIVERSE_SIZE is forbidden and we make it a no-op (which triggers a warning // as MPI_ERR_ARG is returned). Directly calling Comm::attr_put breaks for now, as MPI_UNIVERSE_SIZE,is <0 // instance.comm_world->attr_put(MPI_UNIVERSE_SIZE, reinterpret_cast(instance.size)); diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index 4d3dc3f399..b72ab97504 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -364,7 +364,7 @@ MPI_Comm Comm::find_intra_comm(int * leader){ } } *leader=min_index; - return new Comm(group_intra, nullptr, 1); + return new Comm(group_intra, nullptr, true); } void Comm::init_smp(){ @@ -431,7 +431,7 @@ void Comm::init_smp(){ //create leader_communicator for (i=0; i< leader_group_size;i++) leaders_group->set_mapping(s4u::Actor::by_pid(leader_list[i]).get(), i); - leader_comm = new Comm(leaders_group, nullptr,1); + leader_comm = new Comm(leaders_group, nullptr, true); this->set_leaders_comm(leader_comm); this->set_intra_comm(comm_intra); @@ -441,7 +441,7 @@ void Comm::init_smp(){ leaders_group->set_mapping(s4u::Actor::by_pid(leader_list[i]).get(), i); if(this->get_leaders_comm()==MPI_COMM_NULL){ - leader_comm = new Comm(leaders_group, nullptr,1); + leader_comm = new Comm(leaders_group, nullptr, true); this->set_leaders_comm(leader_comm); }else{ leader_comm=this->get_leaders_comm(); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index f6087ffd53..d1f2593df1 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -144,7 +144,7 @@ kernel::resource::CpuAction* HostL07Model::execute_parallel(const std::vector& host_list, const double* flops_amount, const double* bytes_amount, double rate) - : CpuAction(model, 1, 0), computationAmount_(flops_amount), communicationAmount_(bytes_amount), rate_(rate) + : CpuAction(model, 1.0, false), computationAmount_(flops_amount), communicationAmount_(bytes_amount), rate_(rate) { size_t link_nb = 0; size_t used_host_nb = 0; /* Only the hosts with something to compute (>0 flops) are counted) */ diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 44e77881dd..10d2874153 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -82,7 +82,7 @@ double surf_solve(double max_date) XBT_DEBUG("Looking for next trace event"); - while (1) { // Handle next occurring events until none remains + while (true) { // Handle next occurring events until none remains double next_event_date = simgrid::kernel::profile::future_evt_set.next_date(); XBT_DEBUG("Next TRACE event: %f", next_event_date); diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index b536e7fe51..7f4da38243 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -161,7 +161,7 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) xbt_assert(static_cast(ev->priority) < sizeof(xbt_log_priority_names)/sizeof(xbt_log_priority_names[0]), "Priority %d is greater than the biggest allowed value", ev->priority); - while (1) { + while (true) { const s_xbt_log_appender_t* appender = cat->appender; if (appender != nullptr) { @@ -182,7 +182,7 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) /* The static buffer was too small, use a dynamically expanded one */ ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE; ev->buffer = static_cast(xbt_malloc(ev->buffer_size)); - while (1) { + while (true) { va_start(ev->ap, fmt); done = cat->layout->do_layout(cat->layout, ev, fmt); va_end(ev->ap); diff --git a/src/xbt/xbt_log_layout_format.cpp b/src/xbt/xbt_log_layout_format.cpp index e07eca46dd..9a0e7fe72f 100644 --- a/src/xbt/xbt_log_layout_format.cpp +++ b/src/xbt/xbt_log_layout_format.cpp @@ -30,18 +30,19 @@ static constexpr const char* ERRMSG = } else \ return 0 -#define set_sz_from_precision() \ - if (1) { \ - sz = rem_size; \ - if (precision != -1) { \ - if (precision < sz) \ - sz = precision + 1; /* +1 for the final '\0' */ \ - precision = -1; \ - } \ - } else (void)0 +#define set_sz_from_precision() \ + if (true) { \ + sz = rem_size; \ + if (precision != -1) { \ + if (precision < sz) \ + sz = precision + 1; /* +1 for the final '\0' */ \ + precision = -1; \ + } \ + } else \ + (void)0 #define show_it(data, letter) \ - if (1) { \ + if (true) { \ int len; \ int wd; \ if (length == -1) { \ @@ -58,13 +59,14 @@ static constexpr const char* ERRMSG = } \ check_overflow(len); \ } else \ - (void)0 + (void)0 -#define show_string(data) \ - if (1) { \ - const char *show_string_data = (data); \ - show_it(show_string_data ? show_string_data : "(null)", "s"); \ - } else (void)0 +#define show_string(data) \ + if (true) { \ + const char* show_string_data = (data); \ + show_it(show_string_data ? show_string_data : "(null)", "s"); \ + } else \ + (void)0 #define show_int(data) show_it((data), "d") #define show_double(data) show_it((data), "f") @@ -165,7 +167,7 @@ static int xbt_log_layout_format_doit(const s_xbt_log_layout_t* l, xbt_log_event xbt_abort(); } break; /* done, continue normally */ - } while (1); + } while (true); } else { *p = *q; check_overflow(1); diff --git a/teshsuite/s4u/host-on-off/host-on-off.cpp b/teshsuite/s4u/host-on-off/host-on-off.cpp index 906c5361c5..ff634b9da0 100644 --- a/teshsuite/s4u/host-on-off/host-on-off.cpp +++ b/teshsuite/s4u/host-on-off/host-on-off.cpp @@ -13,7 +13,7 @@ static void worker() const std::string* payload; simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("jupi"); - while (1) { + while (true) { try { payload = static_cast(mailbox->get()); } catch (const simgrid::HostFailureException&) { diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 2cc23e4336..f633892ff3 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -126,7 +126,7 @@ static void server() simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_cname()); XBT_INFO("Server waiting for transfers ..."); - while (1) { + while (true) { const std::string* msg = static_cast(mailbox->get()); if (*msg == "finalize") { // Shutdown ... delete msg; -- 2.20.1