Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless casts.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 28 Jun 2019 07:39:07 +0000 (09:39 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 2 Jul 2019 13:52:52 +0000 (15:52 +0200)
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/xbt_log_layout_format.cpp

index 7d0f2fc..118e736 100644 (file)
@@ -177,9 +177,10 @@ unit_scale::unit_scale(std::initializer_list<std::tuple<const std::string, doubl
 double surf_parse_get_value_with_unit(const char* string, const unit_scale& units, const char* entity_kind,
                                       const std::string& name, const char* error_msg, const char* default_unit)
 {
 double surf_parse_get_value_with_unit(const char* string, const unit_scale& units, const char* entity_kind,
                                       const std::string& name, const char* error_msg, const char* default_unit)
 {
-  char* ptr;
+  char* endptr;
   errno = 0;
   errno = 0;
-  double res   = strtod(string, &ptr);
+  double res      = strtod(string, &endptr);
+  const char* ptr = endptr; // for const-correctness
   if (errno == ERANGE)
     surf_parse_error(std::string("value out of range: ") + string);
   if (ptr == string)
   if (errno == ERANGE)
     surf_parse_error(std::string("value out of range: ") + string);
   if (ptr == string)
@@ -188,7 +189,7 @@ double surf_parse_get_value_with_unit(const char* string, const unit_scale& unit
     // Ok, 0 can be unit-less
     if (res != 0 && not name.empty())
       XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s", string, entity_kind, name.c_str(), error_msg);
     // Ok, 0 can be unit-less
     if (res != 0 && not name.empty())
       XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s", string, entity_kind, name.c_str(), error_msg);
-    ptr = (char*)default_unit;
+    ptr = default_unit;
   }
   auto u = units.find(ptr);
   if (u == units.end())
   }
   auto u = units.find(ptr);
   if (u == units.end())
index 06c9a73..daec92c 100644 (file)
@@ -184,7 +184,7 @@ xbt_log_layout_t xbt_log_layout_format_new(const char* arg)
   xbt_log_layout_t res = xbt_new0(s_xbt_log_layout_t, 1);
   res->do_layout       = &xbt_log_layout_format_doit;
   res->free_           = &xbt_log_layout_format_free;
   xbt_log_layout_t res = xbt_new0(s_xbt_log_layout_t, 1);
   res->do_layout       = &xbt_log_layout_format_doit;
   res->free_           = &xbt_log_layout_format_free;
-  res->data = xbt_strdup((char *) arg);
+  res->data            = xbt_strdup(arg);
 
   return res;
 }
 
   return res;
 }