From 45ee036d5512d088f138c143e8be8c1002e452e4 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 6 Feb 2015 20:32:15 +0000 Subject: Fix undefined behaviours when shifting. Found by libubsan. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14913 a5019735-40e9-0310-863c-91ae7b9d1cf9 --- callgrind/sim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'callgrind') diff --git a/callgrind/sim.c b/callgrind/sim.c index fe1e81e5b..7478a32ed 100644 --- a/callgrind/sim.c +++ b/callgrind/sim.c @@ -183,8 +183,8 @@ static void cachesim_initcache(cache_t config, cache_t2* c) c->sets = (c->size / c->line_size) / c->assoc; c->sets_min_1 = c->sets - 1; c->line_size_bits = VG_(log2)(c->line_size); - c->tag_shift = c->line_size_bits + VG_(log2)(c->sets); - c->tag_mask = ~((1<tag_shift)-1); + c->tag_shift = c->line_size_bits + VG_(log2)(c->sets); + c->tag_mask = ~((1u<tag_shift)-1); /* Can bits in tag entries be used for flags? * Should be always true as MIN_LINE_SIZE >= 16 */ @@ -650,7 +650,7 @@ void cacheuse_initcache(cache_t2* c) else { int bytes_per_bit = c->line_size/32; start_mask = 1; - end_mask = 1 << 31; + end_mask = 1u << 31; for(i=0;iline_size;i++) { c->line_start_mask[i] = start_val; c->line_end_mask[c->line_size-i-1] = end_val; -- cgit v1.2.3