From e7fd9f0fc3eea5c364b2585d744075077e12b3b9 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 12 May 2022 10:29:08 +0200 Subject: [PATCH] Rename variables to avoid shadowed declarations. --- examples/c/app-bittorrent/app-bittorrent.c | 4 ++-- examples/c/app-bittorrent/bittorrent-peer.c | 2 +- examples/c/app-bittorrent/bittorrent-peer.h | 2 +- examples/c/app-bittorrent/tracker.c | 2 +- examples/c/app-bittorrent/tracker.h | 2 +- src/kernel/activity/ActivityImpl.cpp | 8 ++++---- src/kernel/actor/ActorImpl.cpp | 20 ++++++++++---------- src/mc/sosp/Region.cpp | 6 +++--- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/c/app-bittorrent/app-bittorrent.c b/examples/c/app-bittorrent/app-bittorrent.c index e8edbb8e21..71aa208865 100644 --- a/examples/c/app-bittorrent/app-bittorrent.c +++ b/examples/c/app-bittorrent/app-bittorrent.c @@ -20,8 +20,8 @@ int main(int argc, char* argv[]) simgrid_load_platform(argv[1]); - simgrid_register_function("tracker", tracker); - simgrid_register_function("peer", peer); + simgrid_register_function("tracker", tracker_run); + simgrid_register_function("peer", peer_run); simgrid_load_deployment(argv[2]); diff --git a/examples/c/app-bittorrent/bittorrent-peer.c b/examples/c/app-bittorrent/bittorrent-peer.c index 9a0e82669f..2d5275c210 100644 --- a/examples/c/app-bittorrent/bittorrent-peer.c +++ b/examples/c/app-bittorrent/bittorrent-peer.c @@ -77,7 +77,7 @@ static void peer_free(peer_t peer) } /** Peer main function */ -void peer(int argc, char* argv[]) +void peer_run(int argc, char* argv[]) { // Check arguments xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments"); diff --git a/examples/c/app-bittorrent/bittorrent-peer.h b/examples/c/app-bittorrent/bittorrent-peer.h index 6020c06c52..70171a6702 100644 --- a/examples/c/app-bittorrent/bittorrent-peer.h +++ b/examples/c/app-bittorrent/bittorrent-peer.h @@ -57,7 +57,7 @@ typedef s_peer_t* peer_t; typedef const s_peer_t* const_peer_t; /** Peer main function */ -void peer(int argc, char* argv[]); +void peer_run(int argc, char* argv[]); int get_peers_from_tracker(const_peer_t peer); void send_handshake_to_all_peers(const_peer_t peer); diff --git a/examples/c/app-bittorrent/tracker.c b/examples/c/app-bittorrent/tracker.c index d103c5ca50..6014e5ad6f 100644 --- a/examples/c/app-bittorrent/tracker.c +++ b/examples/c/app-bittorrent/tracker.c @@ -25,7 +25,7 @@ static int is_in_list(const_xbt_dynar_t peers, int id) return xbt_dynar_member(peers, &id); } -void tracker(int argc, char* argv[]) +void tracker_run(int argc, char* argv[]) { // Checking arguments xbt_assert(argc == 2, "Wrong number of arguments for the tracker."); diff --git a/examples/c/app-bittorrent/tracker.h b/examples/c/app-bittorrent/tracker.h index 292f0fe629..33e2508e3d 100644 --- a/examples/c/app-bittorrent/tracker.h +++ b/examples/c/app-bittorrent/tracker.h @@ -9,7 +9,7 @@ #include "app-bittorrent.h" #include -void tracker(int argc, char* argv[]); +void tracker_run(int argc, char* argv[]); /** Tasks exchanged between a tracker and peers. */ typedef struct s_tracker_query { int peer_id; // peer id diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index 1c569d273d..c75799ab3f 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -111,13 +111,13 @@ void ActivityImpl::wait_for(actor::ActorImpl* issuer, double timeout) /* we need a sleep action (even when the timeout is infinite) to be notified of host failures */ /* Comms handle that a bit differently of the other activities */ if (auto* comm = dynamic_cast(this)) { - resource::Action* sleep = issuer->get_host()->get_cpu()->sleep(timeout); - sleep->set_activity(comm); + resource::Action* sleep_action = issuer->get_host()->get_cpu()->sleep(timeout); + sleep_action->set_activity(comm); if (issuer == comm->src_actor_) - comm->src_timeout_ = sleep; + comm->src_timeout_ = sleep_action; else - comm->dst_timeout_ = sleep; + comm->dst_timeout_ = sleep_action; } else { SynchroImplPtr synchro(new SynchroImpl([this, issuer]() { this->unregister_simcall(&issuer->simcall_); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index bb502beb1c..bb40b4d284 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -367,17 +367,17 @@ void ActorImpl::resume() activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout) { - activity::ActivityImplPtr sleep = this->sleep(timeout); + activity::ActivityImplPtr sleep_activity = this->sleep(timeout); if (actor->wannadie() || actor->to_be_freed()) { - if (sleep->surf_action_) - sleep->surf_action_->finish(resource::Action::State::FINISHED); + if (sleep_activity->surf_action_) + sleep_activity->surf_action_->finish(resource::Action::State::FINISHED); } else { - actor->on_exit->emplace_back([sleep](bool) { - if (sleep->surf_action_) - sleep->surf_action_->finish(resource::Action::State::FINISHED); + actor->on_exit->emplace_back([sleep_activity](bool) { + if (sleep_activity->surf_action_) + sleep_activity->surf_action_->finish(resource::Action::State::FINISHED); }); } - return sleep; + return sleep_activity; } activity::ActivityImplPtr ActorImpl::sleep(double duration) @@ -386,9 +386,9 @@ activity::ActivityImplPtr ActorImpl::sleep(double duration) throw_exception(std::make_exception_ptr(HostFailureException( XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there."))); - auto sleep = new activity::SleepImpl(); - sleep->set_name("sleep").set_host(host_).set_duration(duration).start(); - return activity::SleepImplPtr(sleep); + auto sleep_activity = new activity::SleepImpl(); + sleep_activity->set_name("sleep").set_host(host_).set_duration(duration).start(); + return activity::SleepImplPtr(sleep_activity); } void ActorImpl::throw_exception(std::exception_ptr e) diff --git a/src/mc/sosp/Region.cpp b/src/mc/sosp/Region.cpp index 74b573f1ce..c11f7810f3 100644 --- a/src/mc/sosp/Region.cpp +++ b/src/mc/sosp/Region.cpp @@ -54,8 +54,8 @@ void* Region::read(void* target, const void* addr, std::size_t size) const xbt_assert(contain(simgrid::mc::remote(addr)), "Trying to read out of the region boundary."); // Last byte of the region: - const void* end = (const char*)addr + size - 1; - if (simgrid::mc::mmu::same_chunk((std::uintptr_t)addr, (std::uintptr_t)end)) { + const void* end_addr = (const char*)addr + size - 1; + if (simgrid::mc::mmu::same_chunk((std::uintptr_t)addr, (std::uintptr_t)end_addr)) { // The memory is contained in a single page: return mc_translate_address_region((uintptr_t)addr, this); } @@ -66,7 +66,7 @@ void* Region::read(void* target, const void* addr, std::size_t size) const // We should remove this assumption. // Page of the last byte of the memory area: - size_t page_end = simgrid::mc::mmu::split((std::uintptr_t)end).first; + size_t page_end = simgrid::mc::mmu::split((std::uintptr_t)end_addr).first; void* dest = target; // iterator in the buffer to where we should copy next -- 2.20.1