lkml.org 
[lkml]   [2021]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH][next] trace: osnoise: Fix u64 less than zero comparison
Date
From: Colin Ian King <colin.king@canonical.com>

The less than zero comparison of the u64 variable 'noise' is always
false because the variable is unsigned. Since the time_sub macro
can potentially return an -ve vale, make the variable a s64 to
fix the issue.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: bce29ac9ce0b ("trace: Add osnoise tracer")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
kernel/trace/trace_osnoise.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 38aa5e208ffd..02c984560ceb 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1040,11 +1040,11 @@ static void osnoise_stop_tracing(void)
static int run_osnoise(void)
{
struct osnoise_variables *osn_var = this_cpu_osn_var();
- u64 noise = 0, sum_noise = 0, max_noise = 0;
+ u64 sum_noise = 0, max_noise = 0;
struct trace_array *tr = osnoise_trace;
u64 start, sample, last_sample;
u64 last_int_count, int_count;
- s64 total, last_total = 0;
+ s64 noise = 0, total, last_total = 0;
struct osnoise_sample s;
unsigned int threshold;
int hw_count = 0;
--
2.31.1
\
 
 \ /
  Last update: 2021-06-29 18:53    [W:0.072 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site