lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <c564da16-062f-4da6-9021-c68f9c6eab63@web.de>
Date: Fri, 19 Jul 2024 16:17:18 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-perf-users@...r.kernel.org, kernel-janitors@...r.kernel.org,
 Adrian Hunter <adrian.hunter@...el.com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Arnaldo Carvalho de Melo <acme@...nel.org>, Ian Rogers <irogers@...gle.com>,
 Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...nel.org>,
 Kan Liang <kan.liang@...ux.intel.com>, Mark Rutland <mark.rutland@....com>,
 Namhyung Kim <namhyung@...nel.org>, Peter Zijlstra <peterz@...radead.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] perf trace: Avoid duplicate code in fprintf_duration()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 19 Jul 2024 16:12:51 +0200

Adjust the colour selection so that a bit of duplicate code can be avoided
in this function implementation.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 tools/perf/builtin-trace.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 8449f2beb54d..e29ae5cb95b0 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1258,12 +1258,16 @@ static size_t fprintf_duration(unsigned long t, bool calculated, FILE *fp)

 	if (!calculated)
 		printed += fprintf(fp, "         ");
-	else if (duration >= 1.0)
-		printed += color_fprintf(fp, PERF_COLOR_RED, "%6.3f ms", duration);
-	else if (duration >= 0.01)
-		printed += color_fprintf(fp, PERF_COLOR_YELLOW, "%6.3f ms", duration);
 	else
-		printed += color_fprintf(fp, PERF_COLOR_NORMAL, "%6.3f ms", duration);
+		printed += color_fprintf(fp,
+					 (duration >= 1.0
+					 ? PERF_COLOR_RED
+					 : (duration >= 0.01
+					   ? PERF_COLOR_YELLOW
+					   : PERF_COLOR_NORMAL)),
+					 "%6.3f ms",
+					 duration);
+
 	return printed + fprintf(fp, "): ");
 }

--
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ