netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Ahern <dsahern@gmail.com>
Cc: "Yoann P." <yoann.p.public@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	netdev@vger.kernel.org
Subject: [PATCH iproute2 net-next 1/3] ss: Discard empty descriptor at the end of buffer, if any, before rendering
Date: Tue, 30 Oct 2018 16:05:18 +0100	[thread overview]
Message-ID: <664b3a17a1902a5fc25e5888aaf38fbc6152122d.1540910943.git.sbrivio@redhat.com> (raw)
In-Reply-To: <cover.1540910943.git.sbrivio@redhat.com>

This will allow us to disable display of any given column.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 misc/ss.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index c8970438ce73..c3f61ef66258 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1245,8 +1245,15 @@ static void render(void)
 
 	token = (struct buf_token *)buffer.head->data;
 
-	/* Ensure end alignment of last token, it wasn't necessarily flushed */
-	buffer.tail->end += buffer.cur->len % 2;
+	if (!buffer.cur->len) {
+		/* Last token was flushed, a new empty descriptor was appended:
+		 * discard it
+		 */
+		buffer.tail->end -= sizeof(buffer.cur->len);
+	} else {
+		/* Last token wasn't flushed: ensure end alignment */
+		buffer.tail->end += buffer.cur->len % 2;
+	}
 
 	render_calc_width();
 
-- 
2.19.1

  reply	other threads:[~2018-10-30 23:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 15:05 [PATCH iproute2 net-next 0/3] ss: Allow selection of columns to be displayed Stefano Brivio
2018-10-30 15:05 ` Stefano Brivio [this message]
2018-10-30 15:05 ` [PATCH iproute2 net-next 2/3] ss: Introduce option to display selected columns only Stefano Brivio
2018-10-30 15:05 ` [PATCH iproute2 net-next 3/3] ss: Beautify output when arbitrary columns are hidden Stefano Brivio
2018-10-30 16:34 ` [PATCH iproute2 net-next 0/3] ss: Allow selection of columns to be displayed David Ahern
2018-10-30 16:38   ` Stephen Hemminger
2018-10-30 16:45     ` David Ahern
2018-10-30 17:34   ` Stefano Brivio
2018-11-01  2:48     ` David Ahern
2018-11-01 21:06       ` Jakub Kicinski
2018-11-01 21:18         ` David Ahern
2018-11-01 21:38           ` Stephen Hemminger
2018-11-02  9:58         ` Stefano Brivio
2018-11-02  9:58       ` Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=664b3a17a1902a5fc25e5888aaf38fbc6152122d.1540910943.git.sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=yoann.p.public@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).