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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191226130615.GA29536@peto-laptopnovy>
Date:   Thu, 26 Dec 2019 14:06:15 +0100
From:   Peter Junos <petoju@...il.com>
To:     Stephen Hemminger <stephen@...workplumber.org>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH] ss: use compact output for undetected screen width

On Wed, Dec 25, 2019 at 12:36:07PM -0800, Stephen Hemminger wrote:
> On Mon, 23 Dec 2019 13:47:16 +0100
> Peter Junos <petoju@...il.com> wrote:
> 
> > This change fixes calculation of width in case user pipes the output.
> > 
> > SS output output works correctly when stdout is a terminal. When one
> > pipes the output, it tries to use 80 or 160 columns. That adds a
> > line-break if user has terminal width of 100 chars and output is of
> > the similar width.
> > 
> > To reproduce the issue, call
> > ss | less
> > and see every other line empty if your screen is between 80 and 160
> > columns wide.
> > 
> > Signed-off-by: Peter Junos <petoju@...il.com>
> 
> I would prefer that if the use pipes the command output to a pipe that
> the line length was assumed to be infinite.

Good point, this is used in min().

> > @@ -1159,7 +1159,13 @@ static int render_screen_width(void)
> >   */
> >  static void render_calc_width(void)
> >  {
> > +	bool compact_output = false;
> >  	int screen_width = render_screen_width();
> > +	if (screen_width == -1) {
> > +		screen_width = 80;
> > +		compact_output = true;
> > +	}
> > +
> >  	struct column *c, *eol = columns - 1;
> >  	int first, len = 0, linecols = 0;
> >  
> 
> With this patch, declarations and code are now mixed (more than before).
> I would expect something like:
> 
> static void render_calc_width(void)
> {
> 	int screen_width, first, len = 0, linecols = 0;
> 	bool compact_output = false;
> 	struct column *c, *eol = columns - 1;
> 
> 	screen_width = render_screen_width();
> 	if (screen_width == -1) {
> 		screen_width = INT_MAX;
> 		compact_output = true;
> 	}

Seems good, I'll send changed patch soon.
Thanks for review!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ