Skip to contentSkip to conversation

contrib/plugins/cache.c: Remove redundant check of l2_access

PATCH Applied Peter Maydell 3 participants 3 messages Jul 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 contrib/plugins/cache.c: Remove redundant check of l2_access

In append_stats_line(), we have an expression
l2_access ? l2_miss_rate : 0.0
But this is inside an if (l2_access && l2_misses) { ... } block, so Coverity points out that the false part of the ?: is dead code.

Remove the unnecessary test.

Resolves: Coverity CID 1522458

---
 contrib/plugins/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/plugins/cache.c +1 -1
index c5c8ac75a9c..512ef6776b7 100644
@@ -558,7 +558,7 @@ static void append_stats_line(GString *line,
                                "  %-12" PRIu64 " %-11" PRIu64 " %10.4lf%%",
                                l2_access,
                                l2_misses,
-                               l2_access ? l2_miss_rate : 0.0);
+                               l2_miss_rate);
     }
 
     g_string_append(line, "\n");
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Peter Maydell

In append_stats_line(), we have an expression

    l2_access ? l2_miss_rate : 0.0

But this is inside an if (l2_access && l2_misses) { ... } block, so Coverity points out that the false part of the ?: is dead code.

Quoted 7 lines

Remove the unnecessary test.

Resolves: Coverity CID 1522458

---
  contrib/plugins/cache.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Applied
#2 lore raw
In reply to Peter Maydell
Quoted 9 lines · Peter Maydell

In append_stats_line(), we have an expression
l2_access ? l2_miss_rate : 0.0
But this is inside an if (l2_access && l2_misses) { ... } block, so Coverity points out that the false part of the ?: is dead code.

Remove the unnecessary test.

Resolves: Coverity CID 1522458

Queued to maintainer/for-9.1, thanks.

Quoted 17 lines
---
 contrib/plugins/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/plugins/cache.c +1 -1
index c5c8ac75a9c..512ef6776b7 100644
@@ -558,7 +558,7 @@ static void append_stats_line(GString *line,
                                "  %-12" PRIu64 " %-11" PRIu64 " %10.4lf%%",
                                l2_access,
                                l2_misses,
-                               l2_access ? l2_miss_rate : 0.0);
+                               l2_miss_rate);
     }
 
     g_string_append(line, "\n");
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro