From: Arnaud Giersch Date: Sat, 22 May 2021 16:22:43 +0000 (+0200) Subject: Coding style: ! -> 'not'. X-Git-Tag: v3.28~252 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b98e2e68753ffbe791c52a3f698fb1a3e726daec Coding style: ! -> 'not'. --- diff --git a/examples/cpp/platform-properties/s4u-platform-properties.cpp b/examples/cpp/platform-properties/s4u-platform-properties.cpp index 1eb7ff4158..6f3f8e3d56 100644 --- a/examples/cpp/platform-properties/s4u-platform-properties.cpp +++ b/examples/cpp/platform-properties/s4u-platform-properties.cpp @@ -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 */ diff --git a/examples/cpp/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp b/examples/cpp/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp index edfc7e4aad..d468267114 100644 --- a/examples/cpp/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp +++ b/examples/cpp/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp @@ -16,7 +16,7 @@ static void competitor(int id) { XBT_INFO("Entering the race..."); std::unique_lock 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)"); diff --git a/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp b/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp index d736085446..c72bb9d99c 100644 --- a/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp +++ b/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp @@ -164,7 +164,7 @@ static std::vector> 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; diff --git a/src/bindings/lua/lua_private.hpp b/src/bindings/lua/lua_private.hpp index 3550376492..7200558a76 100644 --- a/src/bindings/lua/lua_private.hpp +++ b/src/bindings/lua/lua_private.hpp @@ -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; \ } \ diff --git a/src/mc/udpor_global.cpp b/src/mc/udpor_global.cpp index bd38ee7b74..d099ce0463 100644 --- a/src/mc/udpor_global.cpp +++ b/src/mc/udpor_global.cpp @@ -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); } diff --git a/src/plugins/link_energy.cpp b/src/plugins/link_energy.cpp index 97aeb01e23..f97f316b12 100644 --- a/src/plugins/link_energy.cpp +++ b/src/plugins/link_energy.cpp @@ -71,7 +71,7 @@ xbt::Extension 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_; diff --git a/src/plugins/link_load.cpp b/src/plugins/link_load.cpp index 77f4382b94..9373f60f33 100644 --- a/src/plugins/link_load.cpp +++ b/src/plugins/link_load.cpp @@ -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(); // Attach new LinkLoad links created in the future. diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index 870a39788d..5a2e5a8fe8 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -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)\ diff --git a/src/smpi/include/smpi_keyvals.hpp b/src/smpi/include/smpi_keyvals.hpp index d32378651e..e2f9662ad9 100644 --- a/src/smpi/include/smpi_keyvals.hpp +++ b/src/smpi/include/smpi_keyvals.hpp @@ -139,7 +139,7 @@ template 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*)this, elem, keyval,p.first->second,&flag); // overwrite previous value p.first->second = attr_value; diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 2057fd80b4..0da4242748 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -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 diff --git a/src/smpi/plugins/ampi/instr_ampi.cpp b/src/smpi/plugins/ampi/instr_ampi.cpp index 99fa0da047..d1b24a55a6 100644 --- a/src/smpi/plugins/ampi/instr_ampi.cpp +++ b/src/smpi/plugins/ampi/instr_ampi.cpp @@ -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; } diff --git a/src/surf/network_wifi.cpp b/src/surf/network_wifi.cpp index e9eb61d427..655941ce0b 100644 --- a/src/surf/network_wifi.cpp +++ b/src/surf/network_wifi.cpp @@ -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_; } diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index 61f476fa7f..93ed95f57e 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -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); diff --git a/src/xbt/xbt_log_appender_file.cpp b/src/xbt/xbt_log_appender_file.cpp index e014939097..faadee9f33 100644 --- a/src/xbt/xbt_log_appender_file.cpp +++ b/src/xbt/xbt_log_appender_file.cpp @@ -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'; diff --git a/src/xbt/xbt_log_layout_simple.cpp b/src/xbt/xbt_log_layout_simple.cpp index 6b4aa2b0ef..d460805e56 100644 --- a/src/xbt/xbt_log_layout_simple.cpp +++ b/src/xbt/xbt_log_layout_simple.cpp @@ -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); } diff --git a/src/xbt/xbt_replay.cpp b/src/xbt/xbt_replay.cpp index 90ccbdaee8..54cb09e576 100644 --- a/src/xbt/xbt_replay.cpp +++ b/src/xbt/xbt_replay.cpp @@ -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; diff --git a/teshsuite/models/cloud-sharing/cloud-sharing.cpp b/teshsuite/models/cloud-sharing/cloud-sharing.cpp index fa94509e7d..2b14c9dfc3 100644 --- a/teshsuite/models/cloud-sharing/cloud-sharing.cpp +++ b/teshsuite/models/cloud-sharing/cloud-sharing.cpp @@ -24,7 +24,7 @@ static int computation_fun(std::vector 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(pm)) + if (not dynamic_cast(pm)) new_energy += sg_host_get_consumed_energy(pm); } diff --git a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp index 92f2c0df94..6525f735a1 100644 --- a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp +++ b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp @@ -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(); }); 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); diff --git a/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp b/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp index bb92811039..e7c59e6f6a 100644 --- a/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp +++ b/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp @@ -67,11 +67,11 @@ int main(int argc, char** argv) std::vector 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")); } diff --git a/teshsuite/s4u/wait-any-for/wait-any-for.cpp b/teshsuite/s4u/wait-any-for/wait-any-for.cpp index 494d56179d..7f40e7f0d6 100644 --- a/teshsuite/s4u/wait-any-for/wait-any-for.cpp +++ b/teshsuite/s4u/wait-any-for/wait-any-for.cpp @@ -25,7 +25,7 @@ static void worker() XBT_INFO("All comms have started"); std::vector 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");