From patchwork Tue Oct 30 15:05:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 990907 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42kvsr48cPz9s9h for ; Wed, 31 Oct 2018 02:05:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727674AbeJ3X7Y (ORCPT ); Tue, 30 Oct 2018 19:59:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbeJ3X7Y (ORCPT ); Tue, 30 Oct 2018 19:59:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85324C028346; Tue, 30 Oct 2018 15:05:34 +0000 (UTC) Received: from epycfail.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077341054FD9; Tue, 30 Oct 2018 15:05:32 +0000 (UTC) From: Stefano Brivio To: David Ahern Cc: "Yoann P." , Stephen Hemminger , 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 Message-Id: <664b3a17a1902a5fc25e5888aaf38fbc6152122d.1540910943.git.sbrivio@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 30 Oct 2018 15:05:34 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This will allow us to disable display of any given column. Signed-off-by: Stefano Brivio --- 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();