Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Coding style: ! -> 'not'.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 22 May 2021 16:22:43 +0000 (18:22 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 25 May 2021 08:43:38 +0000 (10:43 +0200)
20 files changed:
examples/cpp/platform-properties/s4u-platform-properties.cpp
examples/cpp/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp
examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp
src/bindings/lua/lua_private.hpp
src/mc/udpor_global.cpp
src/plugins/link_energy.cpp
src/plugins/link_load.cpp
src/smpi/include/private.hpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/mpi/smpi_request.cpp
src/smpi/plugins/ampi/instr_ampi.cpp
src/surf/network_wifi.cpp
src/xbt/log.cpp
src/xbt/xbt_log_appender_file.cpp
src/xbt/xbt_log_layout_simple.cpp
src/xbt/xbt_replay.cpp
teshsuite/models/cloud-sharing/cloud-sharing.cpp
teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp
teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp
teshsuite/s4u/wait-any-for/wait-any-for.cpp

index 1eb7ff4..6f3f8e3 100644 (file)
@@ -35,7 +35,8 @@ static void test_host(const std::string& hostname)
   XBT_INFO("== Try to get a host property that does exist");
   value = thehost->get_property(exist);
   xbt_assert(value, "\tProperty %s is undefined (where it should)", exist);
-  xbt_assert(!strcmp(value, "180"), "\tValue of property %s is defined to %s (where it should be 180)", exist, value);
+  xbt_assert(strcmp(value, "180") == 0, "\tValue of property %s is defined to %s (where it should be 180)", exist,
+             value);
   XBT_INFO("   Property: %s old value: %s", exist, value);
 
   XBT_INFO("== Trying to modify a host property");
@@ -44,7 +45,7 @@ static void test_host(const std::string& hostname)
   /* Test if we have changed the value */
   value = thehost->get_property(exist);
   xbt_assert(value, "Property %s is undefined (where it should)", exist);
-  xbt_assert(!strcmp(value, "250"), "Value of property %s is defined to %s (where it should be 250)", exist, value);
+  xbt_assert(strcmp(value, "250") == 0, "Value of property %s is defined to %s (where it should be 250)", exist, value);
   XBT_INFO("   Property: %s old value: %s", exist, value);
 
   /* Restore the value for the next test */
index edfc7e4..d468267 100644 (file)
@@ -16,7 +16,7 @@ static void competitor(int id)
 {
   XBT_INFO("Entering the race...");
   std::unique_lock<simgrid::s4u::Mutex> lck(*mtx);
-  while (!ready) {
+  while (not ready) {
     auto now = simgrid::s4u::Engine::get_clock();
     if (cv->wait_until(lck, now + (id+1)*0.25) == std::cv_status::timeout) {
       XBT_INFO("Out of wait_until (timeout)");
index d736085..c72bb9d 100644 (file)
@@ -164,7 +164,7 @@ static std::vector<std::unique_ptr<Job>> all_jobs(const std::string& workload_fi
 
         // Let's read the filename
         std::ifstream traces_file(job->filename);
-        if (!traces_file.is_open())
+        if (not traces_file.is_open())
           throw std::invalid_argument("Cannot open file " + job->filename);
 
         std::string traces_line;
index 3550376..7200558 100644 (file)
@@ -21,7 +21,7 @@ void sglua_register_platf_functions(lua_State* L);
 #define _lua_ensure_ARG1(cond) _lua_ensure_ARGN((cond), "Assertion " _XBT_STRINGIFY(cond) " failed")
 #define _lua_ensure_ARGN(cond, ...)                                                                                    \
   do {                                                                                                                 \
-    if (!(cond)) {                                                                                                     \
+    if (not(cond)) {                                                                                                   \
       luaL_error(L, __VA_ARGS__);                                                                                      \
       return -1;                                                                                                       \
     }                                                                                                                  \
index bd38ee7..d099ce0 100644 (file)
@@ -22,7 +22,7 @@ EventSet EvtSetTools::makeUnion(const EventSet& s1, const EventSet& s2)
 
 void EvtSetTools::pushBack(EventSet& events, UnfoldingEvent* e)
 {
-  if (!EvtSetTools::contains(events, e))
+  if (not EvtSetTools::contains(events, e))
     events.push_back(e);
 }
 
index 97aeb01..f97f316 100644 (file)
@@ -71,7 +71,7 @@ xbt::Extension<s4u::Link, LinkEnergy> LinkEnergy::EXTENSION_ID;
 
 void LinkEnergy::update()
 {
-  if (!inited_)
+  if (not inited_)
     init_watts_range_list();
 
   double power = get_power();
@@ -125,7 +125,7 @@ void LinkEnergy::init_watts_range_list()
 
 double LinkEnergy::get_power() const
 {
-  if (!inited_)
+  if (not inited_)
     return 0.0;
 
   double power_slope = busy_ - idle_;
index 77f4382..9373f60 100644 (file)
@@ -75,7 +75,7 @@ LinkLoad::LinkLoad(s4u::Link* ptr) : link_(ptr), is_tracked_(false)
 
 void LinkLoad::track()
 {
-  xbt_assert(!is_tracked_, "Trying to track load of link '%s' while it is already tracked, aborting.",
+  xbt_assert(not is_tracked_, "Trying to track load of link '%s' while it is already tracked, aborting.",
              link_->get_cname());
   XBT_DEBUG("Tracking load of link '%s'", link_->get_cname());
 
@@ -187,7 +187,7 @@ static void on_communicate(const simgrid::kernel::resource::NetworkAction& actio
 void sg_link_load_plugin_init()
 {
   xbt_assert(sg_host_count() == 0, "Please call sg_link_load_plugin_init() BEFORE initializing the platform.");
-  xbt_assert(!LinkLoad::EXTENSION_ID.valid(), "Double call to sg_link_load_plugin_init. Aborting.");
+  xbt_assert(not LinkLoad::EXTENSION_ID.valid(), "Double call to sg_link_load_plugin_init. Aborting.");
   LinkLoad::EXTENSION_ID = simgrid::s4u::Link::extension_create<LinkLoad>();
 
   // Attach new LinkLoad links created in the future.
index 870a397..5a2e5a8 100644 (file)
@@ -531,13 +531,13 @@ XBT_PRIVATE void private_execute_flops(double flops);
     }\
   }
 
-#define CHECK_INIT\
-  {\
-    int init_flag=0;\
-    PMPI_Initialized(&init_flag);\
-    CHECK_ARGS((!init_flag), MPI_ERR_OTHER, "%s: MPI_Init was not called !", __func__)\
-    PMPI_Finalized(&init_flag);\
-    CHECK_ARGS((init_flag), MPI_ERR_OTHER, "%s: MPI_Finalize was already called !", __func__)\
+#define CHECK_INIT                                                                                                     \
+  {                                                                                                                    \
+    int init_flag = 0;                                                                                                 \
+    PMPI_Initialized(&init_flag);                                                                                      \
+    CHECK_ARGS(not init_flag, MPI_ERR_OTHER, "%s: MPI_Init was not called !", __func__)                                \
+    PMPI_Finalized(&init_flag);                                                                                        \
+    CHECK_ARGS(init_flag, MPI_ERR_OTHER, "%s: MPI_Finalize was already called !", __func__)                            \
   }
 
 #define CHECK_MPI_NULL(num, val, err, ptr)\
index d323786..e2f9662 100644 (file)
@@ -139,7 +139,7 @@ template <typename T> int Keyval::attr_put(int keyval, void* attr_value){
   elem->refcount++;
   int flag=0;
   auto p = attributes()->insert({keyval, attr_value});
-  if (!p.second) {
+  if (not p.second) {
     int ret = call_deleter<T>((T*)this, elem, keyval,p.first->second,&flag);
     // overwrite previous value
     p.first->second = attr_value;
index 2057fd8..0da4242 100644 (file)
@@ -616,7 +616,7 @@ int Request::test(MPI_Request * request, MPI_Status * status, int* flag) {
         return ret;
       }
     }
-    if (((*request)->flags_ & MPI_REQ_GENERALIZED) && !((*request)->flags_ & MPI_REQ_COMPLETE))
+    if (((*request)->flags_ & MPI_REQ_GENERALIZED) && not((*request)->flags_ & MPI_REQ_COMPLETE))
       *flag=0;
     if (*flag) {
       finish_wait(request, status); // may invalidate *request
@@ -705,9 +705,8 @@ int Request::testany(int count, MPI_Request requests[], int *index, int* flag, M
     
     if (i != -1) { // -1 is not MPI_UNDEFINED but a SIMIX return code. (nothing matches)
       *index = map[i];
-      if (requests[*index] != MPI_REQUEST_NULL && 
-          (requests[*index]->flags_ & MPI_REQ_GENERALIZED)
-          && !(requests[*index]->flags_ & MPI_REQ_COMPLETE)) {
+      if (requests[*index] != MPI_REQUEST_NULL && (requests[*index]->flags_ & MPI_REQ_GENERALIZED) &&
+          not(requests[*index]->flags_ & MPI_REQ_COMPLETE)) {
         *flag=0;
       } else {
         finish_wait(&requests[*index],status);
@@ -1013,7 +1012,7 @@ int Request::wait(MPI_Request * request, MPI_Status * status)
   }
 
   if ((*request)->flags_ & MPI_REQ_GENERALIZED) {
-    if(!((*request)->flags_ & MPI_REQ_COMPLETE)){
+    if (not((*request)->flags_ & MPI_REQ_COMPLETE)) {
       ((*request)->generalized_funcs)->mutex->lock();
       ((*request)->generalized_funcs)->cond->wait(((*request)->generalized_funcs)->mutex);
       ((*request)->generalized_funcs)->mutex->unlock();
@@ -1213,10 +1212,8 @@ int Request::get_status(const Request* req, int* flag, MPI_Status* status)
     if(*flag)
       return MPI_SUCCESS;
   }
-  if (req != MPI_REQUEST_NULL && 
-     (req->flags_ & MPI_REQ_GENERALIZED)
-     && !(req->flags_ & MPI_REQ_COMPLETE)) {
-     *flag=0;
+  if (req != MPI_REQUEST_NULL && (req->flags_ & MPI_REQ_GENERALIZED) && not(req->flags_ & MPI_REQ_COMPLETE)) {
+    *flag = 0;
     return MPI_SUCCESS;
   }
 
@@ -1251,7 +1248,7 @@ int Request::grequest_start(MPI_Grequest_query_function* query_fn, MPI_Grequest_
 
 int Request::grequest_complete(MPI_Request request)
 {
-  if ((!(request->flags_ & MPI_REQ_GENERALIZED)) || request->generalized_funcs->mutex == nullptr)
+  if ((not(request->flags_ & MPI_REQ_GENERALIZED)) || request->generalized_funcs->mutex == nullptr)
     return MPI_ERR_REQUEST;
   request->generalized_funcs->mutex->lock();
   request->flags_ |= MPI_REQ_COMPLETE; // in case wait would be called after complete
index 99fa0da..d1b24a5 100644 (file)
@@ -45,7 +45,7 @@ void TRACE_migration_call(aid_t pid, simgrid::instr::TIData* extra)
     // TI tracing uses states as events, and does not support printing events.
     // So, we need a different code than for replay in order to be able to
     // generate ti_traces for the migration calls.
-    if (!TRACE_smpi_is_enabled()) {
+    if (not TRACE_smpi_is_enabled()) {
       delete extra;
       return;
     }
index e9eb61d..655941c 100644 (file)
@@ -87,7 +87,7 @@ void NetworkWifiLink::refresh_decay_bandwidths(){
 }
 
 bool NetworkWifiLink::toggle_decay_model(){
-  use_decay_model_=!use_decay_model_;
+  use_decay_model_ = not use_decay_model_;
   return use_decay_model_;
 }
 
index 61f476f..93ed95f 100644 (file)
@@ -185,7 +185,7 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
       }
     }
 
-    if (!cat->additivity)
+    if (not cat->additivity)
       break;
     cat = cat->parent;
   }
@@ -231,7 +231,7 @@ static void _xbt_log_cat_apply_set(xbt_log_category_t category, const xbt_log_se
   }
   if (setting.appender) {
     xbt_log_appender_set(category, setting.appender);
-    if (!category->layout)
+    if (not category->layout)
       xbt_log_layout_set(category, xbt_log_layout_simple_new(nullptr));
     category->additivity = 0;
     XBT_DEBUG("Set %p as appender of category '%s'", setting.appender, category->name);
@@ -260,7 +260,7 @@ int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority
     category->appender = xbt_log_default_appender;
     category->layout = xbt_log_default_layout;
   } else {
-    if (!category->parent)
+    if (not category->parent)
       category->parent = &_XBT_LOGV(XBT_LOG_ROOT_CAT);
 
     XBT_DEBUG("Set %s (%s) as father of %s ", category->parent->name,
@@ -320,7 +320,7 @@ void xbt_log_parent_set(xbt_log_category_t cat, xbt_log_category_t parent)
 
   parent->firstChild = cat;
 
-  if (!parent->initialized)
+  if (not parent->initialized)
     _xbt_log_cat_init(parent, xbt_log_priority_uninitialized /* ignored */ );
 
   cat->threshold = parent->threshold;
@@ -356,7 +356,7 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
   const char *orig_control_string = control_string;
   xbt_log_setting_t set;
 
-  if (!*control_string)
+  if (not*control_string)
     return set;
   XBT_DEBUG("Parse log setting '%s'", control_string);
 
@@ -444,7 +444,7 @@ static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, const c
 
 void xbt_log_control_set(const char *control_string)
 {
-  if (!control_string)
+  if (not control_string)
     return;
   XBT_DEBUG("Parse log settings '%s'", control_string);
 
@@ -489,7 +489,7 @@ void xbt_log_appender_set(xbt_log_category_t cat, xbt_log_appender_t app)
 void xbt_log_layout_set(xbt_log_category_t cat, xbt_log_layout_t lay)
 {
   DISABLE_XBT_LOG_CAT_INIT();
-  if (!cat->appender) {
+  if (not cat->appender) {
     XBT_VERB ("No appender to category %s. Setting the file appender as default", cat->name);
     xbt_log_appender_set(cat, xbt_log_appender_file_new(nullptr));
   }
@@ -575,7 +575,7 @@ static void xbt_log_help()
 
 static void xbt_log_help_categories_rec(xbt_log_category_t category, const std::string& prefix)
 {
-  if (!category)
+  if (not category)
     return;
 
   std::string this_prefix(prefix);
index e014939..faadee9 100644 (file)
@@ -59,7 +59,7 @@ static constexpr const char* APPEND2_END_TOKEN_CLEAR = "\n                   ";
 static void open_append2_file(xbt_log_append2_file_t data){
   if(data->count<0) {
     //Roll
-    if (!data->file) {
+    if (not data->file) {
       data->file= fopen(data->filename, "w");
       xbt_assert(data->file != nullptr, "Cannot open file: %s: %s", data->filename, strerror(errno));
     } else {
@@ -72,7 +72,7 @@ static void open_append2_file(xbt_log_append2_file_t data){
       fclose(data->file);
     char* pre=xbt_strdup(data->filename);
     char* sep=strchr(pre,'%');
-    if(!sep)
+    if (not sep)
       sep=pre+strlen(pre);
     const char* post    = sep + 1;
     *sep                = '\0';
index 6b4aa2b..d460805 100644 (file)
@@ -38,8 +38,7 @@ static bool xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_
   if (procname && strcmp(procname,"maestro")) {
     len = snprintf(p, rem_size, "%s:%s:(%d) ", sg_host_self_get_name(), procname, xbt_getpid());
     check_overflow(len);
-  }
-  else if (!procname)  {
+  } else if (not procname) {
     len = snprintf(p, rem_size, "%s::(%d) ", sg_host_self_get_name(), xbt_getpid());
     check_overflow(len);
   }
@@ -49,7 +48,7 @@ static bool xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_
   check_overflow(len);
 
   /* Display file position if not INFO */
-  if (ev->priority != xbt_log_priority_info && !xbt_log_no_loc) {
+  if (ev->priority != xbt_log_priority_info && not xbt_log_no_loc) {
     len = snprintf(p, rem_size, "%s:%d: ", ev->fileName, ev->lineNum);
     check_overflow(len);
   }
index 90ccbda..54cb09e 100644 (file)
@@ -121,7 +121,7 @@ int replay_runner(const char* actor_name, const char* trace_filename)
                "any. Please use xbt_replay_set_tracefile().");
     while (true) {
       simgrid::xbt::ReplayAction* evt = simgrid::xbt::get_action(actor_name);
-      if (!evt)
+      if (not evt)
         break;
       simgrid::xbt::handle_action(*evt);
       delete evt;
index fa94509..2b14c9d 100644 (file)
@@ -24,7 +24,7 @@ static int computation_fun(std::vector<std::string> argv)
   double end = simgrid::s4u::Engine::get_clock();
 
   if (0.1 - (end - begin) > 0.001) {
-    xbt_assert(!FAIL_ON_ERROR, "%s with %.4g load (%dflops) took %.4fs instead of 0.1s",
+    xbt_assert(not FAIL_ON_ERROR, "%s with %.4g load (%dflops) took %.4fs instead of 0.1s",
                simgrid::s4u::this_actor::get_name().c_str(), ((double)size / flop_amount), size, (end - begin));
     XBT_INFO("FAILED TEST: %s with %.4g load (%dflops) took %.4fs instead of 0.1s",
              simgrid::s4u::this_actor::get_name().c_str(), ((double)size / flop_amount), size, (end - begin));
@@ -49,7 +49,7 @@ static void test_energy_consumption(const std::string& name, int nb_cores)
   double new_energy = 0;
 
   for (simgrid::s4u::Host* pm : simgrid::s4u::Engine::get_instance()->get_all_hosts()) {
-    if (!dynamic_cast<simgrid::s4u::VirtualMachine*>(pm))
+    if (not dynamic_cast<simgrid::s4u::VirtualMachine*>(pm))
       new_energy += sg_host_get_consumed_energy(pm);
   }
 
index 92f2c0d..6525f73 100644 (file)
@@ -78,7 +78,7 @@ void run_ping_test(const char* src, const char* dest, int data_size)
   simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(dest),
                               [mailbox]() { mailbox->get<std::string>(); });
   auto* l = (simgrid::kernel::resource::NetworkWifiLink*)simgrid::s4u::Link::by_name("AP1")->get_impl();
-  if (!l->toggle_decay_model())
+  if (not l->toggle_decay_model())
     l->toggle_decay_model();
   l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
   l->set_host_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
index bb92811..e7c59e6 100644 (file)
@@ -67,11 +67,11 @@ int main(int argc, char** argv)
 
   std::vector<sg4::Host*> hosts = e.get_all_hosts();
   if (argc >= 3) {
-    if (!strcmp(argv[2], "ONE_LINK"))
+    if (strcmp(argv[2], "ONE_LINK") == 0)
       test_one_link(hosts);
-    if (!strcmp(argv[2], "FULL_LINK"))
+    if (strcmp(argv[2], "FULL_LINK") == 0)
       test_full_link(hosts);
-    if (!strcmp(argv[2], "PROP"))
+    if (strcmp(argv[2], "PROP") == 0)
       XBT_INFO("SG_TEST_mem: %s", sg4::Host::by_name("host1")->get_property("SG_TEST_mem"));
   }
 
index 494d561..7f40e7f 100644 (file)
@@ -25,7 +25,7 @@ static void worker()
   XBT_INFO("All comms have started");
   std::vector<simgrid::s4u::CommPtr> comms = {put1, put2, get1, get2};
 
-  while (!comms.empty()) {
+  while (not comms.empty()) {
     int index = simgrid::s4u::Comm::wait_any_for(&comms, 0.5);
     if (index < 0)
       XBT_INFO("wait_any_for: Timeout reached");