From: Arnaud Giersch Date: Sat, 30 Apr 2022 13:08:59 +0000 (+0200) Subject: Declare local variables inside the if statement. X-Git-Tag: v3.32~279 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/cee8b7d98f1c3b6738ad5f0b20de7bed9ba08d5a Declare local variables inside the if statement. --- diff --git a/examples/cpp/dag-comm/s4u-dag-comm.cpp b/examples/cpp/dag-comm/s4u-dag-comm.cpp index a1cb5c9ef5..a6d4a98c06 100644 --- a/examples/cpp/dag-comm/s4u-dag-comm.cpp +++ b/examples/cpp/dag-comm/s4u-dag-comm.cpp @@ -26,12 +26,10 @@ int main(int argc, char* argv[]) }); sg4::Activity::on_completion_cb([](sg4::Activity const& activity) { - const auto* exec = dynamic_cast(&activity); - if (exec != nullptr) + if (const auto* exec = dynamic_cast(&activity)) XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(), exec->get_finish_time()); - const auto* comm = dynamic_cast(&activity); - if (comm != nullptr) + if (const auto* comm = dynamic_cast(&activity)) XBT_INFO("Activity '%s' is complete", comm->get_cname()); }); diff --git a/examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp b/examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp index bcd18ded8d..a1b8538fbb 100644 --- a/examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp +++ b/examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp @@ -51,8 +51,7 @@ int main(int argc, char** argv) exec->set_host(hosts[cursor % count]); cursor++; } - auto* comm = dynamic_cast(a.get()); - if (comm != nullptr) { + if (auto* comm = dynamic_cast(a.get())) { auto pred = dynamic_cast((*comm->get_dependencies().begin()).get()); auto succ = dynamic_cast(comm->get_successors().front().get()); comm->set_source(pred->get_host())->set_destination(succ->get_host()); @@ -64,13 +63,11 @@ int main(int argc, char** argv) XBT_INFO("-------------- Summary of executed schedule ------------------"); for (const auto& a : dag) { - const auto* exec = dynamic_cast(a.get()); - if (exec != nullptr) { + if (const auto* exec = dynamic_cast(a.get())) { XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(), exec->get_host()->get_cname()); } - const auto* comm = dynamic_cast(a.get()); - if (comm != nullptr) { + if (const auto* comm = dynamic_cast(a.get())) { XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(), comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname()); } diff --git a/examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp b/examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp index 10d32a5b3b..ca994ac0d2 100644 --- a/examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp +++ b/examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp @@ -49,8 +49,7 @@ int main(int argc, char** argv) exec->set_host(hosts[cursor % count]); cursor++; } - auto* comm = dynamic_cast(a.get()); - if (comm != nullptr) { + if (auto* comm = dynamic_cast(a.get())) { auto pred = dynamic_cast((*comm->get_dependencies().begin()).get()); auto succ = dynamic_cast(comm->get_successors().front().get()); comm->set_source(pred->get_host())->set_destination(succ->get_host()); @@ -62,13 +61,11 @@ int main(int argc, char** argv) XBT_INFO("-------------- Summary of executed schedule ------------------"); for (const auto& a : dag) { - const auto* exec = dynamic_cast(a.get()); - if (exec != nullptr) { + if (const auto* exec = dynamic_cast(a.get())) { XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(), exec->get_host()->get_cname()); } - const auto* comm = dynamic_cast(a.get()); - if (comm != nullptr) { + if (const auto* comm = dynamic_cast(a.get())) { XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(), comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname()); } diff --git a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp index 40a9ad3057..155a84b479 100644 --- a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp +++ b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp @@ -55,13 +55,11 @@ static std::vector get_ready_tasks(const std::vectordependencies_solved() && not a->is_assigned()) { // if it is an exec, it's ready - auto* exec = dynamic_cast(a.get()); - if (exec != nullptr) + if (auto* exec = dynamic_cast(a.get())) ready_tasks.push_back(exec); // if it a comm, we consider its successor as a candidate. If a candidate solves all its dependencies, // i.e., get all its input data, it's ready - const auto* comm = dynamic_cast(a.get()); - if (comm != nullptr) { + if (const auto* comm = dynamic_cast(a.get())) { auto* next_exec = static_cast(comm->get_successors().front().get()); candidate_execs[next_exec]++; if (next_exec->get_dependencies().size() == candidate_execs[next_exec]) @@ -86,8 +84,7 @@ static double finish_on_at(const sg4::ExecPtr task, const sg4::Host* host) last_data_available = -1.0; for (const auto& parent : parents) { /* normal case */ - const auto* comm = dynamic_cast(parent.get()); - if (comm != nullptr) { + if (const auto* comm = dynamic_cast(parent.get())) { auto source = comm->get_source(); XBT_DEBUG("transfer from %s to %s", source->get_cname(), host->get_cname()); /* Estimate the redistribution time from this parent */ @@ -103,9 +100,8 @@ static double finish_on_at(const sg4::ExecPtr task, const sg4::Host* host) data_available = *comm->get_data() + redist_time; } - const auto* exec = dynamic_cast(parent.get()); /* no transfer, control dependency */ - if (exec != nullptr) { + if (const auto* exec = dynamic_cast(parent.get())) { data_available = exec->get_finish_time(); } diff --git a/examples/cpp/dht-kademlia/node.cpp b/examples/cpp/dht-kademlia/node.cpp index 4437cc2ede..4e64641b7d 100644 --- a/examples/cpp/dht-kademlia/node.cpp +++ b/examples/cpp/dht-kademlia/node.cpp @@ -50,8 +50,7 @@ bool Node::join(unsigned int known_id) XBT_DEBUG("Received an answer from the node I know."); got_answer = true; // retrieve the node list and ping them. - const Answer* node_list = msg->answer_.get(); - if (node_list) { + if (const Answer* node_list = msg->answer_.get()) { for (auto const& [contact, _] : node_list->getNodes()) routingTableUpdate(contact); } else { diff --git a/include/simgrid/plugins/ProducerConsumer.hpp b/include/simgrid/plugins/ProducerConsumer.hpp index 66381ca638..6f4f909aef 100644 --- a/include/simgrid/plugins/ProducerConsumer.hpp +++ b/include/simgrid/plugins/ProducerConsumer.hpp @@ -205,8 +205,7 @@ public: T* get() { T* data; - s4u::CommPtr comm = get_async(&data); - if (comm) { + if (s4u::CommPtr comm = get_async(&data)) { XBT_CDEBUG(producer_consumer, "Waiting for the data to arrive"); comm->wait(); } diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index cbafbe50a5..83cd96603d 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -339,15 +339,11 @@ static void on_action_state_change(kernel::resource::Action const& action, double value = action.get_rate() * action.get_variable()->get_constraint_weight(i); /* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */ kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id(); - const kernel::resource::CpuImpl* cpu = dynamic_cast(resource); - - if (cpu != nullptr) + if (const auto* cpu = dynamic_cast(resource)) resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value, action.get_last_update(), simgrid_get_clock() - action.get_last_update()); - const kernel::resource::StandardLinkImpl* link = dynamic_cast(resource); - - if (link != nullptr) + if (const auto* link = dynamic_cast(resource)) resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action.get_category(), value, action.get_last_update(), simgrid_get_clock() - action.get_last_update()); } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 0d511d79af..e2baf29d70 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -297,8 +297,7 @@ resource::StandardLinkImpl* NetZoneImpl::get_link_by_name_or_null(const std::str return link_it->second; for (const auto* child : children_) { - auto* link = child->get_link_by_name_or_null(name); - if (link) + if (auto* link = child->get_link_by_name_or_null(name)) return link; } @@ -312,8 +311,7 @@ resource::SplitDuplexLinkImpl* NetZoneImpl::get_split_duplex_link_by_name_or_nul return link_it->second.get(); for (const auto* child : children_) { - auto* link = child->get_split_duplex_link_by_name_or_null(name); - if (link) + if (auto* link = child->get_split_duplex_link_by_name_or_null(name)) return link; } diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index 419a839f74..21bb7a3ff7 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -842,11 +842,9 @@ static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* static Elf64_Half get_type(Elf* elf) { - const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf); - if (ehdr64) + if (const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf)) return ehdr64->e_type; - const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf); - if (ehdr32) + if (const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf)) return ehdr32->e_type; xbt_die("Could not get ELF heeader"); } @@ -994,15 +992,13 @@ static void MC_load_dwarf(simgrid::mc::ObjectInformation* info) info->flags |= simgrid::mc::ObjectInformation::Executable; // Read DWARF debug information in the file: - Dwarf* dwarf = dwarf_begin_elf(elf, DWARF_C_READ, nullptr); - if (dwarf != nullptr) { + if (Dwarf* dwarf = dwarf_begin_elf(elf, DWARF_C_READ, nullptr)) { read_dwarf_info(info, dwarf); dwarf_end(dwarf); elf_end(elf); close(fd); return; } - dwarf_end(dwarf); // If there was no DWARF in the file, try to find it in a separate file. // Different methods might be used to store the DWARF information: @@ -1027,7 +1023,7 @@ static void MC_load_dwarf(simgrid::mc::ObjectInformation* info) // Load the DWARF info from this file: XBT_DEBUG("Load DWARF for %s", info->file_name.c_str()); - dwarf = dwarf_begin(fd, DWARF_C_READ); + Dwarf* dwarf = dwarf_begin(fd, DWARF_C_READ); xbt_assert(dwarf != nullptr, "No DWARF info for %s", info->file_name.c_str()); read_dwarf_info(info, dwarf); dwarf_end(dwarf); @@ -1116,8 +1112,7 @@ static simgrid::mc::Type* MC_resolve_type(simgrid::mc::ObjectInformation* info, // Try to find a more complete description of the type: // We need to fix in order to support C++. - simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(info->full_types_by_name, type->name); - if (subtype) + if (simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(info->full_types_by_name, type->name)) type = *subtype; return type; } diff --git a/src/mc/remote/RemoteProcess.cpp b/src/mc/remote/RemoteProcess.cpp index dda2716d97..3923fd86c7 100644 --- a/src/mc/remote/RemoteProcess.cpp +++ b/src/mc/remote/RemoteProcess.cpp @@ -319,8 +319,7 @@ std::string RemoteProcess::read_string(RemotePtr address) const continue; xbt_assert(c > 0, "Could not read string from remote process"); - const void* p = memchr(res.data() + off, '\0', c); - if (p) + if (const void* p = memchr(res.data() + off, '\0', c)) return std::string(res.data()); off += c; diff --git a/src/mc/transition/Transition.cpp b/src/mc/transition/Transition.cpp index 64cb123651..c01936c0de 100644 --- a/src/mc/transition/Transition.cpp +++ b/src/mc/transition/Transition.cpp @@ -60,9 +60,7 @@ Transition* deserialize_transition(aid_t issuer, int times_considered, std::stri xbt_assert(type >= 0 && type <= static_cast(Transition::Type::UNKNOWN), "Invalid transition type %d received", type); - auto simcall = static_cast(type); - - switch (simcall) { + switch (auto simcall = static_cast(type)) { case Transition::Type::BARRIER_LOCK: case Transition::Type::BARRIER_WAIT: return new BarrierTransition(issuer, times_considered, simcall, stream); diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 98acd5957a..bedefd7cd5 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -342,19 +342,17 @@ int File::remote_move(sg_host_t host, const std::string& fullpath) FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr) { - const char* size_str = ptr->get_property("size"); - std::string dummyfile; - if (size_str) + if (const char* size_str = ptr->get_property("size")) { + std::string dummyfile; size_ = xbt_parse_get_size(dummyfile, -1, size_str, "disk size " + ptr->get_name()); + } - const char* current_mount_str = ptr->get_property("mount"); - if (current_mount_str) + if (const char* current_mount_str = ptr->get_property("mount")) mount_point_ = std::string(current_mount_str); else mount_point_ = std::string("/"); - const char* content_str = ptr->get_property("content"); - if (content_str) + if (const char* content_str = ptr->get_property("content")) content_.reset(parse_content(content_str)); } diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index e9099cd508..0404ae069f 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -110,19 +110,16 @@ public: void init() { - const char* local_sampling_rate_config = host_->get_property(cfg_sampling_rate.get_name()); - if (local_sampling_rate_config != nullptr) { + if (const char* local_sampling_rate_config = host_->get_property(cfg_sampling_rate.get_name())) { sampling_rate_ = std::stod(local_sampling_rate_config); } else { sampling_rate_ = cfg_sampling_rate; } - const char* local_min_pstate_config = host_->get_property(cfg_min_pstate.get_name()); - if (local_min_pstate_config != nullptr) { + if (const char* local_min_pstate_config = host_->get_property(cfg_min_pstate.get_name())) { min_pstate = std::stoul(local_min_pstate_config); } - const char* local_max_pstate_config = host_->get_property(cfg_max_pstate.get_name()); - if (local_max_pstate_config != nullptr) { + if (const char* local_max_pstate_config = host_->get_property(cfg_max_pstate.get_name())) { max_pstate = std::stoul(local_max_pstate_config); } xbt_assert(max_pstate <= host_->get_pstate_count() - 1, "Value for max_pstate too large!"); @@ -385,8 +382,7 @@ static void on_host_added(simgrid::s4u::Host& host) XBT_DEBUG("DVFS process on %s is a daemon: %d", daemon_proc->get_host()->get_cname(), daemon_proc->is_daemon()); std::string dvfs_governor; - const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor"); - if (host_conf != nullptr) { + if (const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor")) { dvfs_governor = std::string(host_conf); boost::algorithm::to_lower(dvfs_governor); } else { diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index ef191bfd51..fa9578f3f1 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -414,8 +414,7 @@ static void on_action_state_change(simgrid::kernel::resource::CpuAction const& a simgrid::s4u::Host* host = cpu->get_iface(); if (host != nullptr) { // If it's a VM, take the corresponding PM - const simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); - if (vm) // If it's a VM, take the corresponding PM + if (const auto* vm = dynamic_cast(host)) host = vm->get_pm(); // Get the host_energy extension for the relevant host @@ -492,8 +491,7 @@ void sg_host_energy_plugin_init() simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) { if (activity.get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = activity.get_host(); - const simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); - if (vm != nullptr) + if (const auto* vm = dynamic_cast(host)) host = vm->get_pm(); xbt_assert(host != nullptr); host->extension()->update(); diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index 3484d05f69..da3e76a946 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -237,8 +237,7 @@ void sg_host_load_plugin_init() simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) { if (activity.get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = activity.get_host(); - const simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); - if (vm != nullptr) + if (const auto* vm = dynamic_cast(host)) host = vm->get_pm(); xbt_assert(host != nullptr); host->extension()->add_activity(static_cast(activity.get_impl())); @@ -256,8 +255,7 @@ void sg_host_load_plugin_init() return; if (exec->get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = exec->get_host(); - const simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); - if (vm != nullptr) + if (const auto* vm = dynamic_cast(host)) host = vm->get_pm(); xbt_assert(host != nullptr); host->extension()->update(); diff --git a/src/plugins/link_energy_wifi.cpp b/src/plugins/link_energy_wifi.cpp index 60d067b3d0..954a54f782 100644 --- a/src/plugins/link_energy_wifi.cpp +++ b/src/plugins/link_energy_wifi.cpp @@ -211,8 +211,7 @@ void LinkEnergyWifi::init_watts_range_list() Set to 0 if you do not want to compute beacons, otherwise to the duration of beacons transmissions per second */ - const char* beacons_factor = this->link_->get_property("control_duration"); - if(beacons_factor != nullptr) { + if (const char* beacons_factor = this->link_->get_property("control_duration")) { try { control_duration_ = std::stod(beacons_factor); } catch (const std::invalid_argument&) { diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index a183594a21..119fe5910f 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -325,16 +325,14 @@ static int smpi_run_entry_point(const F& entry_point, const std::string& executa static smpi_entry_point_type smpi_resolve_function(void* handle) { - auto* entry_point_fortran = reinterpret_cast(dlsym(handle, "user_main_")); - if (entry_point_fortran != nullptr) { + if (auto* entry_point_fortran = reinterpret_cast(dlsym(handle, "user_main_"))) { return [entry_point_fortran](int, char**) { entry_point_fortran(); return 0; }; } - auto* entry_point = reinterpret_cast(dlsym(handle, "main")); - if (entry_point != nullptr) { + if (auto* entry_point = reinterpret_cast(dlsym(handle, "main"))) { return entry_point; } diff --git a/src/smpi/internals/smpi_host.cpp b/src/smpi/internals/smpi_host.cpp index 60816f9e43..e3ed32273c 100644 --- a/src/smpi/internals/smpi_host.cpp +++ b/src/smpi/internals/smpi_host.cpp @@ -137,24 +137,21 @@ Host::Host(s4u::Host* ptr) : host(ptr) smpi::Host::EXTENSION_ID = s4u::Host::extension_create(); check_factor_configs("smpi/or"); - const char* orecv_string = host->get_property("smpi/or"); - if (orecv_string != nullptr) { + if (const char* orecv_string = host->get_property("smpi/or")) { orecv_parsed_values = simgrid::smpi::utils::parse_factor(orecv_string); } else { orecv_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value("smpi/or")); } check_factor_configs("smpi/os"); - const char* osend_string = host->get_property("smpi/os"); - if (osend_string != nullptr) { + if (const char* osend_string = host->get_property("smpi/os")) { osend_parsed_values = simgrid::smpi::utils::parse_factor(osend_string); } else { osend_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value("smpi/os")); } check_factor_configs("smpi/ois"); - const char* oisend_string = host->get_property("smpi/ois"); - if (oisend_string != nullptr) { + if (const char* oisend_string = host->get_property("smpi/ois")) { oisend_parsed_values = simgrid::smpi::utils::parse_factor(oisend_string); } else { oisend_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value("smpi/ois")); diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 8561d66313..74fa8f6df2 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -61,8 +61,7 @@ Request::Request(const void* buf, int count, MPI_Datatype datatype, aid_t src, a detached_sender_ = nullptr; real_src_ = 0; // get src_host if it's available (src is valid) - auto src_process = simgrid::s4u::Actor::by_pid(src); - if (src_process) + if (auto src_process = simgrid::s4u::Actor::by_pid(src)) src_host_ = src_process->get_host(); truncated_ = false; unmatched_types_ = false; diff --git a/src/surf/disk_s19.cpp b/src/surf/disk_s19.cpp index e638f1fc58..d1df923827 100644 --- a/src/surf/disk_s19.cpp +++ b/src/surf/disk_s19.cpp @@ -65,8 +65,7 @@ DiskAction* DiskS19Model::io_start(const DiskImpl* disk, sg_size_t size, s4u::Io default: THROW_UNIMPLEMENTED; } - const auto& factor_cb = disk->get_factor_cb(); - if (factor_cb) { // handling disk variability + if (const auto& factor_cb = disk->get_factor_cb()) { // handling disk variability action->set_rate_factor(factor_cb(size, type)); } return action; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index f885a28e80..57af0e9544 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -244,8 +244,7 @@ static void sg_platf_new_cluster_hierarchical(const simgrid::kernel::routing::Cl static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationArgs* cluster) { auto* zone = simgrid::s4u::create_star_zone(cluster->id); - simgrid::s4u::NetZone const* parent = current_routing ? current_routing->get_iface() : nullptr; - if (parent) + if (const auto* parent = current_routing ? current_routing->get_iface() : nullptr) zone->set_parent(parent); /* set properties */ diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index 3d89d6deb3..2852cf8e95 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -151,9 +151,7 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) "Priority %d is greater than the biggest allowed value", ev->priority); while (true) { - const s_xbt_log_appender_t* appender = cat->appender; - - if (appender != nullptr) { + if (const s_xbt_log_appender_t* appender = cat->appender) { xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name); /* First, try with a static buffer */