From: Arnaud Giersch Date: Thu, 26 Dec 2019 13:38:47 +0000 (+0100) Subject: Use type bool for boolean variables. X-Git-Tag: v3.25~211 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/df0ad90cff845556fb7bb2a6fd6e2c10196f5776 Use type bool for boolean variables. --- diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index 7ea070edbd..e52394c887 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -20,9 +20,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(s4u_chord); * @param id id to check * @param start lower bound * @param end upper bound - * @return a non-zero value if id in in [start, end] + * @return true if id in in [start, end] */ -static int is_in_interval(int id, int start, int end) +static bool is_in_interval(int id, int start, int end) { int i = id % nb_keys; int s = start % nb_keys; diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index b082826fcc..aeceb03484 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -87,9 +87,9 @@ void System::check_concurrency() const continue; const Element& elem = var.cnsts_[0]; - int belong_to_enabled = elem.enabled_element_set_hook.is_linked(); - int belong_to_disabled = elem.disabled_element_set_hook.is_linked(); - int belong_to_active = elem.active_element_set_hook.is_linked(); + bool belong_to_enabled = elem.enabled_element_set_hook.is_linked(); + bool belong_to_disabled = elem.disabled_element_set_hook.is_linked(); + bool belong_to_active = elem.active_element_set_hook.is_linked(); for (Element const& elem2 : var.cnsts_) { xbt_assert(belong_to_enabled == elem2.enabled_element_set_hook.is_linked(), @@ -827,8 +827,8 @@ void System::update_variable_penalty(Variable* var, double penalty) if (penalty == var->sharing_penalty_) return; - int enabling_var = (penalty > 0 && var->sharing_penalty_ <= 0); - int disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0); + bool enabling_var = (penalty > 0 && var->sharing_penalty_ <= 0); + bool disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0); XBT_IN("(sys=%p, var=%p, penalty=%f)", this, var, penalty); diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index 4244c994d3..3f7dd3878a 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -337,7 +337,7 @@ public: /** @brief Check if a variable can be enabled * Make sure to set staged_penalty before, if your intent is only to check concurrency */ - int can_enable() const { return staged_penalty_ > 0 && get_min_concurrency_slack() >= concurrency_share_; } + bool can_enable() const { return staged_penalty_ > 0 && get_min_concurrency_slack() >= concurrency_share_; } /* hookup to system */ boost::intrusive::list_member_hook<> variable_set_hook_; diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 7800a145b8..756c7d6f2a 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -62,7 +62,7 @@ void parse_platform_file(const std::string& file) { const char* cfile = file.c_str(); int len = strlen(cfile); - int is_lua = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a'; + bool is_lua = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a'; sg_platf_init(); diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 6e885360be..e02222fe94 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -63,19 +63,16 @@ static void xbt_postexit(); #ifndef __GNUC__ /* Should not be necessary but for some reason, DllMain is called twice at attachment and at detachment.*/ -static int xbt_dll_process_is_attached = 0; - /* see also http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx */ /* and http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx */ static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - if (fdwReason == DLL_PROCESS_ATTACH - && xbt_dll_process_is_attached == 0) { - xbt_dll_process_is_attached = 1; + static bool xbt_dll_process_is_attached = false; + if (fdwReason == DLL_PROCESS_ATTACH && not xbt_dll_process_is_attached) { + xbt_dll_process_is_attached = true; xbt_preinit(); - } else if (fdwReason == DLL_PROCESS_DETACH - && xbt_dll_process_is_attached == 1) { - xbt_dll_process_is_attached = 0; + } else if (fdwReason == DLL_PROCESS_DETACH && xbt_dll_process_is_attached) { + xbt_dll_process_is_attached = false; } return 1; }