diff mbox series

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

Message ID 20240725164851.1930964-1-peter.maydell@linaro.org
State New
Headers show
Series contrib/plugins/cache.c: Remove redundant check of l2_access | expand

Commit Message

Peter Maydell July 25, 2024, 4:48 p.m. UTC
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
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 contrib/plugins/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé July 25, 2024, 7:55 p.m. UTC | #1
On 25/7/24 18:48, Peter Maydell wrote:
> 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
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   contrib/plugins/cache.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Alex Bennée July 25, 2024, 8:30 p.m. UTC | #2
Peter Maydell <peter.maydell@linaro.org> writes:

> 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
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Queued to maintainer/for-9.1, thanks.

> ---
>  contrib/plugins/cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
> index c5c8ac75a9c..512ef6776b7 100644
> --- a/contrib/plugins/cache.c
> +++ b/contrib/plugins/cache.c
> @@ -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");
diff mbox series

Patch

diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
index c5c8ac75a9c..512ef6776b7 100644
--- a/contrib/plugins/cache.c
+++ b/contrib/plugins/cache.c
@@ -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");