[PATCH i-g-t] tools/intel_gpu_top: Fix near full percentage bar formatting

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Thu Jan 18 08:48:38 UTC 2024


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Fix a bug where 1) the end vertical separator element would not be printed
if the progress bar portion was all filled by the progress bar characters
(no trailing spaces), and 2) the numerical overlay would be skipped to.

The bug would also shift the layout of following UI elements since the
progress bar would not be consuming all the allocated horizontal space.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Reported-by: anonymoustranquillity at proton.me
---
 tools/intel_gpu_top.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 046ead15a122..5b4f94d7de7a 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -1015,9 +1015,8 @@ print_percentage_bar(double percent, double max, int max_len, bool numeric)
 		printf("%s", bars[i]);
 
 	len -= (bar_len + (w - 1)) / w;
-	if (len < 1)
-		return;
-	n_spaces(len);
+	if (len >= 1)
+		n_spaces(len);
 
 	putchar('|');
 
-- 
2.40.1



More information about the igt-dev mailing list