naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0002-lnstat-fix-header-displaying-mechanism.patch

049c96
From 54a2e1a045adae87ccd7b3047c1ccc3b1eea1351 Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Tue, 16 Feb 2016 20:48:44 +0100
049c96
Subject: [PATCH] lnstat: fix header displaying mechanism
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1263392
049c96
Upstream Status: commit fdb347f7fd6c3
049c96
Conflicts: Patch practically rewritten due to missing commit
049c96
	   a4f9e8df37b23 ("lnstat: add json output format") and
049c96
	   follow-ups.
049c96
049c96
commit fdb347f7fd6c36b270a8c571cbe9a124a281b2b5
049c96
Author: Phil Sutter <phil@nwl.cc>
049c96
Date:   Wed Nov 18 16:57:47 2015 +0100
049c96
049c96
    lnstat: fix header displaying mechanism
049c96
049c96
    The algorithm depends on the loop counter ('i') to increment by one in
049c96
    each iteration. Though if running endlessly (count==0), the counter was
049c96
    not incremented at all.
049c96
049c96
    Also change formatting of the header printing conditional a bit so it's
049c96
    hopefully easier to read.
049c96
049c96
    Fixes: e7e2913 ("lnstat: run indefinitely by default")
049c96
    Signed-off-by: Phil Sutter <phil@nwl.cc>
049c96
---
049c96
 misc/lnstat.c | 9 ++++-----
049c96
 1 file changed, 4 insertions(+), 5 deletions(-)
049c96
049c96
diff --git a/misc/lnstat.c b/misc/lnstat.c
049c96
index fcd7dd3..f2bb695 100644
049c96
--- a/misc/lnstat.c
049c96
+++ b/misc/lnstat.c
049c96
@@ -332,16 +332,15 @@ int main(int argc, char **argv)
049c96
 		if (interval < 1 )
049c96
 			interval=1;
049c96
 
049c96
-		for (i = 0; i < count || !count; ) {
049c96
-			if  ((hdr > 1 && (! (i % 20))) || (hdr == 1 && i == 0))
049c96
-				print_hdr(stdout, header);
049c96
+		for (i = 0; i < count || !count; i++) {
049c96
 			lnstat_update(lnstat_files);
049c96
+			if  ((hdr > 1 && !(i % 20)) ||
049c96
+			     (hdr == 1 && i == 0))
049c96
+				print_hdr(stdout, header);
049c96
 			print_line(stdout, lnstat_files, &fp);
049c96
 			fflush(stdout);
049c96
 			if (i < count - 1 || !count)
049c96
 				sleep(interval);
049c96
-			if (count)
049c96
-				++i;
049c96
 		}
049c96
 	}
049c96
 
049c96
-- 
049c96
1.8.3.1
049c96