]> sourceware.org Git - valgrind.git/commitdiff
cachegrind: exit with error if line size or associativity is zero
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 30 Sep 2023 19:54:21 +0000 (21:54 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 30 Sep 2023 19:54:21 +0000 (21:54 +0200)
Detected with Coverity

cachegrind/cg_arch.c

index 9b6071d2c3bc013d0530c94647bc3ee91d37b643..dac22feb2af04e5630f6b410a4a7628e3cd152ed 100644 (file)
@@ -41,6 +41,16 @@ static void configure_caches(cache_t* I1c, cache_t* D1c, cache_t* LLc,
 // string otherwise.
 static const HChar* check_cache(cache_t* cache)
 {
+   if (cache->line_size == 0)
+   {
+      return "Cache line size is zero.\n";
+   }
+
+   if (cache->assoc == 0)
+   {
+      return "Cache associativity is zero.\n";
+   }
+
    // Simulator requires set count to be a power of two.
    if ((cache->size % (cache->line_size * cache->assoc) != 0) ||
        (-1 == VG_(log2)(cache->size/cache->line_size/cache->assoc)))
This page took 0.031165 seconds and 5 git commands to generate.