From: Florian Krohm Date: Wed, 5 Aug 2015 13:23:11 +0000 (+0000) Subject: The number of elements in a RangeMap cannot be negative. X-Git-Tag: svn/VALGRIND_3_11_0~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=130cf6ffca8bfc324287459c52a60c3328d5dde3;p=thirdparty%2Fvalgrind.git The number of elements in a RangeMap cannot be negative. Let the return type of VG_(sizeRangeMap) reflect that. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15492 --- diff --git a/coregrind/m_rangemap.c b/coregrind/m_rangemap.c index daed001c50..0703c41908 100644 --- a/coregrind/m_rangemap.c +++ b/coregrind/m_rangemap.c @@ -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, diff --git a/include/pub_tool_rangemap.h b/include/pub_tool_rangemap.h index 657fad60e6..152e9c91f4 100644 --- a/include/pub_tool_rangemap.h +++ b/include/pub_tool_rangemap.h @@ -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, diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 5c3635d468..8af7e17ecd 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -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)); } }