diff mbox series

[1/3] ss: prevent "Process" column from being printed unless requested

Message ID 20231128023058.53546-2-qde@naccy.de (mailing list archive)
State Superseded
Delegated to: David Ahern
Headers show
Series ss: pretty-printing BPF socket-local storage | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Quentin Deslandes Nov. 28, 2023, 2:30 a.m. UTC
Commit 5883c6eba517 ("ss: show header for --processes/-p") added
"Process" to the list of columns printed by ss. However, the "Process"
header is now printed even if --processes/-p is not used.

This change aims to fix this by moving the COL_PROC column ID to the same
index as the corresponding column structure in the columns array, and
enabling it if --processes/-p is used.

Signed-off-by: Quentin Deslandes <qde@naccy.de>
---
 misc/ss.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

David Ahern Nov. 29, 2023, 12:20 a.m. UTC | #1
On 11/27/23 7:30 PM, Quentin Deslandes wrote:
> Commit 5883c6eba517 ("ss: show header for --processes/-p") added
> "Process" to the list of columns printed by ss. However, the "Process"
> header is now printed even if --processes/-p is not used.
> 
> This change aims to fix this by moving the COL_PROC column ID to the same
> index as the corresponding column structure in the columns array, and
> enabling it if --processes/-p is used.
> 
> Signed-off-by: Quentin Deslandes <qde@naccy.de>
> ---
>  misc/ss.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/misc/ss.c b/misc/ss.c
> index 9438382b..09dc1f37 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -100,8 +100,8 @@ enum col_id {
>  	COL_SERV,
>  	COL_RADDR,
>  	COL_RSERV,
> -	COL_EXT,
>  	COL_PROC,
> +	COL_EXT,
>  	COL_MAX
>  };
>  
> @@ -5795,6 +5795,9 @@ int main(int argc, char *argv[])
>  	if (ssfilter_parse(&current_filter.f, argc, argv, filter_fp))
>  		usage();
>  
> +	if (!show_processes)
> +		columns[COL_PROC].disabled = 1;
> +
>  	if (!(current_filter.dbs & (current_filter.dbs - 1)))
>  		columns[COL_NETID].disabled = 1;
>  

this one should go into main as a bug fix. Resubmit as a standalone
patch with:

Fixes: 5883c6eba517 ("ss: show header for --processes/-p")
diff mbox series

Patch

diff --git a/misc/ss.c b/misc/ss.c
index 9438382b..09dc1f37 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -100,8 +100,8 @@  enum col_id {
 	COL_SERV,
 	COL_RADDR,
 	COL_RSERV,
-	COL_EXT,
 	COL_PROC,
+	COL_EXT,
 	COL_MAX
 };
 
@@ -5795,6 +5795,9 @@  int main(int argc, char *argv[])
 	if (ssfilter_parse(&current_filter.f, argc, argv, filter_fp))
 		usage();
 
+	if (!show_processes)
+		columns[COL_PROC].disabled = 1;
+
 	if (!(current_filter.dbs & (current_filter.dbs - 1)))
 		columns[COL_NETID].disabled = 1;