Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Declare local variables inside the if statement.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 30 Apr 2022 13:08:59 +0000 (15:08 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 3 May 2022 19:04:32 +0000 (21:04 +0200)
22 files changed:
examples/cpp/dag-comm/s4u-dag-comm.cpp
examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp
examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp
examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp
examples/cpp/dht-kademlia/node.cpp
include/simgrid/plugins/ProducerConsumer.hpp
src/instr/instr_platform.cpp
src/kernel/routing/NetZoneImpl.cpp
src/mc/inspect/mc_dwarf.cpp
src/mc/remote/RemoteProcess.cpp
src/mc/transition/Transition.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/plugins/link_energy_wifi.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_host.cpp
src/smpi/mpi/smpi_request.cpp
src/surf/disk_s19.cpp
src/surf/sg_platf.cpp
src/xbt/log.cpp

index a1cb5c9..a6d4a98 100644 (file)
@@ -26,12 +26,10 @@ int main(int argc, char* argv[])
   });
 
   sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
-    const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
-    if (exec != nullptr)
+    if (const auto* exec = dynamic_cast<sg4::Exec const*>(&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<sg4::Comm const*>(&activity);
-    if (comm != nullptr)
+    if (const auto* comm = dynamic_cast<sg4::Comm const*>(&activity))
       XBT_INFO("Activity '%s' is complete", comm->get_cname());
   });
 
index bcd18de..a1b8538 100644 (file)
@@ -51,8 +51,7 @@ int main(int argc, char** argv)
       exec->set_host(hosts[cursor % count]);
       cursor++;
     }
-    auto* comm = dynamic_cast<sg4::Comm*>(a.get());
-    if (comm != nullptr) {
+    if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
       auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
       auto succ = dynamic_cast<sg4::Exec*>(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<sg4::Exec*>(a.get());
-    if (exec != nullptr) {
+    if (const auto* exec = dynamic_cast<sg4::Exec*>(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<sg4::Comm*>(a.get());
-    if (comm != nullptr) {
+    if (const auto* comm = dynamic_cast<sg4::Comm*>(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());
     }
index 10d32a5..ca994ac 100644 (file)
@@ -49,8 +49,7 @@ int main(int argc, char** argv)
       exec->set_host(hosts[cursor % count]);
       cursor++;
     }
-    auto* comm = dynamic_cast<sg4::Comm*>(a.get());
-    if (comm != nullptr) {
+    if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
       auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
       auto succ = dynamic_cast<sg4::Exec*>(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<sg4::Exec*>(a.get());
-    if (exec != nullptr) {
+    if (const auto* exec = dynamic_cast<sg4::Exec*>(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<sg4::Comm*>(a.get());
-    if (comm != nullptr) {
+    if (const auto* comm = dynamic_cast<sg4::Comm*>(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());
     }
index 40a9ad3..155a84b 100644 (file)
@@ -55,13 +55,11 @@ static std::vector<sg4::Exec*> get_ready_tasks(const std::vector<sg4::ActivityPt
     // Only look at activity that have their dependencies solved but are not assigned
     if (a->dependencies_solved() && not a->is_assigned()) {
       // if it is an exec, it's ready
-      auto* exec = dynamic_cast<sg4::Exec*>(a.get());
-      if (exec != nullptr)
+      if (auto* exec = dynamic_cast<sg4::Exec*>(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<sg4::Comm*>(a.get());
-      if (comm != nullptr) {
+      if (const auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
         auto* next_exec = static_cast<sg4::Exec*>(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<sg4::Comm*>(parent.get());
-      if (comm != nullptr) {
+      if (const auto* comm = dynamic_cast<sg4::Comm*>(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<double>() + redist_time;
       }
 
-      const auto* exec = dynamic_cast<sg4::Exec*>(parent.get());
       /* no transfer, control dependency */
-      if (exec != nullptr) {
+      if (const auto* exec = dynamic_cast<sg4::Exec*>(parent.get())) {
         data_available = exec->get_finish_time();
       }
 
index 4437cc2..4e64641 100644 (file)
@@ -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 {
index 66381ca..6f4f909 100644 (file)
@@ -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();
     }
index cbafbe5..83cd966 100644 (file)
@@ -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<kernel::resource::CpuImpl*>(resource);
-
-    if (cpu != nullptr)
+    if (const auto* cpu = dynamic_cast<kernel::resource::CpuImpl*>(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<kernel::resource::StandardLinkImpl*>(resource);
-
-    if (link != nullptr)
+    if (const auto* link = dynamic_cast<kernel::resource::StandardLinkImpl*>(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());
   }
index 0d511d7..e2baf29 100644 (file)
@@ -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;
   }
 
index 419a839..21bb7a3 100644 (file)
@@ -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;
 }
index dda2716..3923fd8 100644 (file)
@@ -319,8 +319,7 @@ std::string RemoteProcess::read_string(RemotePtr<char> 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;
index 64cb123..c01936c 100644 (file)
@@ -60,9 +60,7 @@ Transition* deserialize_transition(aid_t issuer, int times_considered, std::stri
   xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
              type);
 
-  auto simcall = static_cast<Transition::Type>(type);
-
-  switch (simcall) {
+  switch (auto simcall = static_cast<Transition::Type>(type)) {
     case Transition::Type::BARRIER_LOCK:
     case Transition::Type::BARRIER_WAIT:
       return new BarrierTransition(issuer, times_considered, simcall, stream);
index 98acd59..bedefd7 100644 (file)
@@ -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));
 }
 
index e9099cd..0404ae0 100644 (file)
@@ -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 {
index ef191bf..fa9578f 100644 (file)
@@ -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<simgrid::s4u::VirtualMachine*>(host);
-      if (vm) // If it's a VM, take the corresponding PM
+      if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(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<simgrid::s4u::VirtualMachine*>(host);
-      if (vm != nullptr)
+      if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
         host = vm->get_pm();
       xbt_assert(host != nullptr);
       host->extension<HostEnergy>()->update();
index 3484d05..da3e76a 100644 (file)
@@ -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<simgrid::s4u::VirtualMachine*>(host);
-      if (vm != nullptr)
+      if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
         host = vm->get_pm();
       xbt_assert(host != nullptr);
       host->extension<HostLoad>()->add_activity(static_cast<simgrid::kernel::activity::ExecImpl*>(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<simgrid::s4u::VirtualMachine*>(host);
-      if (vm != nullptr)
+      if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
         host = vm->get_pm();
       xbt_assert(host != nullptr);
       host->extension<HostLoad>()->update();
index 60d067b..954a54f 100644 (file)
@@ -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&) {
index a183594..119fe59 100644 (file)
@@ -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<smpi_fortran_entry_point_type>(dlsym(handle, "user_main_"));
-  if (entry_point_fortran != nullptr) {
+  if (auto* entry_point_fortran = reinterpret_cast<smpi_fortran_entry_point_type>(dlsym(handle, "user_main_"))) {
     return [entry_point_fortran](int, char**) {
       entry_point_fortran();
       return 0;
     };
   }
 
-  auto* entry_point = reinterpret_cast<smpi_c_entry_point_type>(dlsym(handle, "main"));
-  if (entry_point != nullptr) {
+  if (auto* entry_point = reinterpret_cast<smpi_c_entry_point_type>(dlsym(handle, "main"))) {
     return entry_point;
   }
 
index 60816f9..e3ed322 100644 (file)
@@ -137,24 +137,21 @@ Host::Host(s4u::Host* ptr) : host(ptr)
     smpi::Host::EXTENSION_ID = s4u::Host::extension_create<Host>();
 
   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<std::string>("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<std::string>("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<std::string>("smpi/ois"));
index 8561d66..74fa8f6 100644 (file)
@@ -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;
index e638f1f..d1df923 100644 (file)
@@ -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;
index f885a28..57af0e9 100644 (file)
@@ -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 */
index 3d89d6d..2852cf8 100644 (file)
@@ -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 */