Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use type bool for boolean variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Dec 2019 13:38:47 +0000 (14:38 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 27 Dec 2019 11:13:49 +0000 (12:13 +0100)
examples/s4u/dht-chord/s4u-dht-chord-node.cpp
src/kernel/lmm/maxmin.cpp
src/kernel/lmm/maxmin.hpp
src/surf/xml/surfxml_parseplatf.cpp
src/xbt/xbt_main.cpp

index 7ea070e..e52394c 100644 (file)
@@ -20,9 +20,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(s4u_chord);
  * @param id id to check
  * @param start lower bound
  * @param end upper bound
  * @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;
 {
   int i = id % nb_keys;
   int s = start % nb_keys;
index b082826..aeceb03 100644 (file)
@@ -87,9 +87,9 @@ void System::check_concurrency() const
       continue;
 
     const Element& elem    = var.cnsts_[0];
       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(),
 
     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;
 
   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);
 
 
   XBT_IN("(sys=%p, var=%p, penalty=%f)", this, var, penalty);
 
index 4244c99..3f7dd38 100644 (file)
@@ -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
    */
   /** @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_;
 
   /* hookup to system */
   boost::intrusive::list_member_hook<> variable_set_hook_;
index 7800a14..756c7d6 100644 (file)
@@ -62,7 +62,7 @@ void parse_platform_file(const std::string& file)
 {
   const char* cfile = file.c_str();
   int len           = strlen(cfile);
 {
   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();
 
 
   sg_platf_init();
 
index 6e88536..e02222f 100644 (file)
@@ -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.*/
 
 #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)
 {
 /* 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();
     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;
 }
   }
   return 1;
 }