Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use correct type for variables, and avoid loosing precision.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 4 Jul 2020 20:48:52 +0000 (22:48 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 4 Jul 2020 21:39:17 +0000 (23:39 +0200)
src/xbt/automaton/automaton.c
src/xbt/mmalloc/mmalloc.c
src/xbt/mmalloc/mrealloc.c
teshsuite/simdag/availability/availability.c
teshsuite/simdag/basic-parsing-test/basic-parsing-test.c
teshsuite/smpi/bug-17132/bug-17132.c

index 1d6be9f..5fc60df 100644 (file)
@@ -329,9 +329,9 @@ int xbt_automaton_exp_label_compare(const_xbt_automaton_exp_label_t l1, const_xb
 
 int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2)
 {
-  unsigned int nb_elem = xbt_dynar_length(s1);
+  unsigned long nb_elem = xbt_dynar_length(s1);
 
-  for (unsigned int cursor = 0; cursor < nb_elem; cursor++) {
+  for (unsigned long cursor = 0; cursor < nb_elem; cursor++) {
     const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
     const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
     if(*iptr1 != *iptr2)
index 4eb0133..d3c26bb 100644 (file)
@@ -54,7 +54,7 @@ static void initialize_heapinfo_heapinfo(const s_xbt_mheap_t* mdp)
 {
   // Update heapinfo about the heapinfo pages (!):
   xbt_assert((uintptr_t) mdp->heapinfo % BLOCKSIZE == 0);
-  int block = BLOCK(mdp->heapinfo);
+  size_t block   = BLOCK(mdp->heapinfo);
   size_t nblocks = mdp->heapsize * sizeof(malloc_info) / BLOCKSIZE;
   // Mark them as free:
   for (size_t j=0; j!=nblocks; ++j) {
index 186cc66..4ce18de 100644 (file)
@@ -79,7 +79,7 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size)
     /* Full blocks -> Full blocks; see if we can hold it in place. */
     blocks = BLOCKIFY(size);
     if (blocks < mdp->heapinfo[block].busy_block.size) {
-      int it;
+      size_t it;
       /* The new size is smaller; return excess memory to the free list. */
       for (it= block+blocks; it< mdp->heapinfo[block].busy_block.size ; it++){
         mdp->heapinfo[it].type = MMALLOC_TYPE_UNFRAGMENTED; // FIXME that should be useless, type should already be 0 here
@@ -134,7 +134,7 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size)
       /* The new size is the same kind of fragment.  */
 
       result = ptr;
-      int frag_nb = RESIDUAL(result, BLOCKSIZE) >> type;
+      uintptr_t frag_nb                                 = RESIDUAL(result, BLOCKSIZE) >> type;
       mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = requested_size;
       mdp->heapinfo[block].busy_frag.ignore[frag_nb] = 0;
 
index 6c30765..16fe88f 100644 (file)
@@ -21,7 +21,7 @@ static void scheduleDAX(const_xbt_dynar_t dax)
   SD_task_t task;
 
   sg_host_t *hosts = sg_host_list();
-  int totalHosts = sg_host_count();
+  size_t totalHosts = sg_host_count();
   qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
 
   xbt_dynar_foreach(dax, cursor, task) {
index 4a075a8..5464341 100644 (file)
@@ -37,11 +37,11 @@ int main(int argc, char **argv)
       xbt_dynar_free_container(&route);
     }
     if (!strcmp(argv[2], "FULL_LINK")) {
-      int list_size = sg_host_count();
-      for (int i = 0; i < list_size; i++) {
+      size_t list_size = sg_host_count();
+      for (size_t i = 0; i < list_size; i++) {
         const_sg_host_t h1 = hosts[i];
         const char *name1 = sg_host_get_name(h1);
-        for (int j = 0; j < list_size; j++) {
+        for (size_t j = 0; j < list_size; j++) {
           const_sg_host_t h2 = hosts[j];
           const char *name2 = sg_host_get_name(h2);
           fprintf(stderr, "Route between %s and %s\n", name1, name2);
index 16c35f2..bb9cd25 100644 (file)
@@ -11,8 +11,8 @@
 
 int main(int argc, char ** argv)
 {
-  size_t M = 8*1024;
-  size_t N = 32*1024;
+  const int M = 8 * 1024;
+  const int N = 32 * 1024;
 
   MPI_Init(&argc, &argv);