diff mbox series

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

Message ID 20240118084838.734165-1-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [i-g-t] tools/intel_gpu_top: Fix near full percentage bar formatting | expand

Commit Message

Tvrtko Ursulin Jan. 18, 2024, 8:48 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
Reported-by: anonymoustranquillity@proton.me
---
 tools/intel_gpu_top.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Kamil Konieczny March 22, 2024, 10:38 a.m. UTC | #1
Hi Tvrtko,
On 2024-01-18 at 08:48:38 +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
> Reported-by: anonymoustranquillity@proton.me

Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>

> ---
>  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
>
diff mbox series

Patch

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('|');