]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
The number of elements in a RangeMap cannot be negative.
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 5 Aug 2015 13:23:11 +0000 (13:23 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 5 Aug 2015 13:23:11 +0000 (13:23 +0000)
Let the return type of VG_(sizeRangeMap) reflect that.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15492

coregrind/m_rangemap.c
include/pub_tool_rangemap.h
memcheck/mc_main.c

index daed001c5008a8b60a1534ba5b35be34a21f9ce1..0703c419081ca814e3eddfb5ec57aba23e33611f 100644 (file)
@@ -123,10 +123,12 @@ void VG_(lookupRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
    *val     = rng->val;
 }
 
-Word VG_(sizeRangeMap) ( const RangeMap* rm )
+UInt VG_(sizeRangeMap) ( const RangeMap* rm )
 {
    vg_assert(rm && rm->ranges);
-   return VG_(sizeXA)(rm->ranges);
+   Word size = VG_(sizeXA)(rm->ranges);
+   vg_assert(size >= 0);
+   return size;
 }
 
 void VG_(indexRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
index 657fad60e6ba325125c74a8c2177604633b08cc0..152e9c91f4e94c2e069c903b766969e926c3c514 100644 (file)
@@ -71,7 +71,7 @@ void VG_(lookupRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
                            /*OUT*/UWord* val, const RangeMap* rm, UWord key );
 
 /* How many elements are there in the map? */
-Word VG_(sizeRangeMap) ( const RangeMap* rm );
+UInt VG_(sizeRangeMap) ( const RangeMap* rm );
 
 /* Get the i'th component */
 void VG_(indexRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
index 5c3635d468a5cb116d9c1bf8895eae11d72bd7da..8af7e17ecd4ed3c032ebaf4b47892b855d5967d5 100644 (file)
@@ -1177,17 +1177,17 @@ static Bool modify_ignore_ranges ( Bool addRange, Addr start, Addr len )
                    (void*)start, (void*)(start+len-1));
    }
    if (verbose) {
-      VG_(dmsg)("memcheck:   now have %ld ranges:\n",
+      VG_(dmsg)("memcheck:   now have %u ranges:\n",
                 VG_(sizeRangeMap)(gIgnoredAddressRanges));
-      Word i;
+      UInt i;
       for (i = 0; i < VG_(sizeRangeMap)(gIgnoredAddressRanges); i++) {
          UWord val     = IAR_INVALID;
          UWord key_min = ~(UWord)0;
          UWord key_max = (UWord)0;
          VG_(indexRangeMap)( &key_min, &key_max, &val,
                              gIgnoredAddressRanges, i );
-         VG_(dmsg)("memcheck:      [%ld]  %016llx-%016llx  %s\n",
-                   i, (ULong)key_min, (ULong)key_max, showIARKind(val));
+         VG_(dmsg)("memcheck:      [%u]  %016lx-%016lx  %s\n",
+                   i, key_min, key_max, showIARKind(val));
       }
    }
    return True;
@@ -5820,7 +5820,7 @@ static Bool mc_process_cmd_line_options(const HChar* arg)
          return False;
       }
       if (gIgnoredAddressRanges) {
-         Word i;
+         UInt i;
          for (i = 0; i < VG_(sizeRangeMap)(gIgnoredAddressRanges); i++) {
             UWord val     = IAR_INVALID;
             UWord key_min = ~(UWord)0;
@@ -7536,7 +7536,7 @@ static void mc_fini ( Int exitcode )
       pertain to hardware mapped into the address space, and so we
       can't expect the client to have got rid of them. */
    if (gIgnoredAddressRanges) {
-      Word i, nBad = 0;
+      UInt i, nBad = 0;
       for (i = 0; i < VG_(sizeRangeMap)(gIgnoredAddressRanges); i++) {
          UWord val     = IAR_INVALID;
          UWord key_min = ~(UWord)0;
@@ -7558,8 +7558,8 @@ static void mc_fini ( Int exitcode )
                  "VALGRIND_{DISABLE,ENABLE}_ERROR_REPORTING_IN_RANGE macros.\n"
             );
          }
-         VG_(umsg)("   [%ld]  0x%016llx-0x%016llx  %s\n",
-                   i, (ULong)key_min, (ULong)key_max, showIARKind(val));
+         VG_(umsg)("   [%u]  0x%016lx-0x%016lx  %s\n",
+                   i, key_min, key_max, showIARKind(val));
       }
    }