svn commit: r340459 - stable/12/usr.bin/systat

Michael Tuexen tuexen at FreeBSD.org
Thu Nov 15 17:25:34 UTC 2018


Author: tuexen
Date: Thu Nov 15 17:25:32 2018
New Revision: 340459
URL: https://svnweb.freebsd.org/changeset/base/340459

Log:
  MFC r340361:
  
  Fix printing of 64-bit counters on 32-bit ppc platforms.
  
  Several statistic counters are uint64_t values and are printed by systat
  using %lu. This results in displaying wrong numbers. Use PRIu64 instead.
  While there, print variables of size_t using %zd.
  
  Approved by:		re (gjb@)
  Differential Revision:	https://reviews.freebsd.org/D17838

Modified:
  stable/12/usr.bin/systat/fetch.c
  stable/12/usr.bin/systat/icmp6.c
  stable/12/usr.bin/systat/ip.c
  stable/12/usr.bin/systat/ip6.c
  stable/12/usr.bin/systat/tcp.c
  stable/12/usr.bin/systat/zarc.c

Modified: stable/12/usr.bin/systat/fetch.c
==============================================================================
--- stable/12/usr.bin/systat/fetch.c	Thu Nov 15 17:05:02 2018	(r340458)
+++ stable/12/usr.bin/systat/fetch.c	Thu Nov 15 17:25:32 2018	(r340459)
@@ -68,9 +68,8 @@ void getsysctl(const char *name, void *ptr, size_t len
 		    strerror(errno));
 	}
 	if (nlen != len) {
-		error("sysctl(%s...) expected %lu, got %lu", name,
-		    (unsigned long)len, (unsigned long)nlen);
-    }
+		error("sysctl(%s...) expected %zu, got %zu", name, len, nlen);
+	}
 }
 
 /*

Modified: stable/12/usr.bin/systat/icmp6.c
==============================================================================
--- stable/12/usr.bin/systat/icmp6.c	Thu Nov 15 17:05:02 2018	(r340458)
+++ stable/12/usr.bin/systat/icmp6.c	Thu Nov 15 17:25:32 2018	(r340459)
@@ -50,6 +50,7 @@ static char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6
 #include <netinet/in.h>
 #include <netinet/icmp6.h>
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <paths.h>
@@ -173,7 +174,7 @@ void
 showicmp6(void)
 {
 	struct icmp6stat stats;
-	u_long totalin, totalout;
+	uint64_t totalin, totalout;
 	int i;
 
 	memset(&stats, 0, sizeof stats);
@@ -184,11 +185,11 @@ showicmp6(void)
 	}
 	totalin += stats.icp6s_badcode + stats.icp6s_badlen +
 		stats.icp6s_checksum + stats.icp6s_tooshort;
-	mvwprintw(wnd, 1, 0, "%9lu", totalin);
-	mvwprintw(wnd, 1, 35, "%9lu", totalout);
+	mvwprintw(wnd, 1, 0, "%9"PRIu64, totalin);
+	mvwprintw(wnd, 1, 35, "%9"PRIu64, totalout);
 
 #define DO(stat, row, col) \
-	mvwprintw(wnd, row, col, "%9lu", stats.stat)
+	mvwprintw(wnd, row, col, "%9"PRIu64, stats.stat)
 
 	DO(icp6s_badcode, 2, 0);
 	DO(icp6s_badlen, 3, 0);

Modified: stable/12/usr.bin/systat/ip.c
==============================================================================
--- stable/12/usr.bin/systat/ip.c	Thu Nov 15 17:05:02 2018	(r340458)
+++ stable/12/usr.bin/systat/ip.c	Thu Nov 15 17:25:32 2018	(r340459)
@@ -53,6 +53,7 @@ static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkele
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <paths.h>
@@ -203,16 +204,16 @@ void
 showip(void)
 {
 	struct stat stats;
-	u_long totalout;
+	uint64_t totalout;
 
 	domode(&stats);
 	totalout = stats.i.ips_forward + stats.i.ips_localout;
 
 #define DO(stat, row, col) \
-	mvwprintw(wnd, row, col, "%9lu", stats.stat)
+	mvwprintw(wnd, row, col, "%9"PRIu64, stats.stat)
 
 	DO(i.ips_total, 1, 0);
-	mvwprintw(wnd, 1, 35, "%9lu", totalout);
+	mvwprintw(wnd, 1, 35, "%9"PRIu64, totalout);
 	DO(i.ips_badsum, 2, 0);
 	DO(i.ips_localout, 2, 35);
 	DO(i.ips_tooshort, 3, 0);

Modified: stable/12/usr.bin/systat/ip6.c
==============================================================================
--- stable/12/usr.bin/systat/ip6.c	Thu Nov 15 17:05:02 2018	(r340458)
+++ stable/12/usr.bin/systat/ip6.c	Thu Nov 15 17:25:32 2018	(r340459)
@@ -52,6 +52,7 @@ static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkele
 #include <netinet/ip.h>
 #include <netinet6/ip6_var.h>
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <paths.h>
@@ -190,16 +191,16 @@ void
 showip6(void)
 {
 	struct ip6stat stats;
-	u_long totalout;
+	uint64_t totalout;
 
 	domode(&stats);
 	totalout = stats.ip6s_forward + stats.ip6s_localout;
 
 #define DO(stat, row, col) \
-	mvwprintw(wnd, row, col, "%9lu", stats.stat)
+	mvwprintw(wnd, row, col, "%9"PRIu64, stats.stat)
 
 	DO(ip6s_total, 1, 0);
-	mvwprintw(wnd, 1, 35, "%9lu", totalout);
+	mvwprintw(wnd, 1, 35, "%9"PRIu64, totalout);
 	DO(ip6s_tooshort, 2, 0);
 	DO(ip6s_localout, 2, 35);
 	DO(ip6s_toosmall, 3, 0);

Modified: stable/12/usr.bin/systat/tcp.c
==============================================================================
--- stable/12/usr.bin/systat/tcp.c	Thu Nov 15 17:05:02 2018	(r340458)
+++ stable/12/usr.bin/systat/tcp.c	Thu Nov 15 17:25:32 2018	(r340459)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <paths.h>
@@ -237,7 +238,7 @@ showtcp(void)
 	domode(&stats);
 
 #define DO(stat, row, col) \
-	mvwprintw(wnd, row, col, "%12lu", stats.stat)
+	mvwprintw(wnd, row, col, "%12"PRIu64, stats.stat)
 #define	L(row, stat) DO(stat, row, 0)
 #define	R(row, stat) DO(stat, row, 38)
 	L(1, tcps_connattempt);		R(1, tcps_sndtotal);

Modified: stable/12/usr.bin/systat/zarc.c
==============================================================================
--- stable/12/usr.bin/systat/zarc.c	Thu Nov 15 17:05:02 2018	(r340458)
+++ stable/12/usr.bin/systat/zarc.c	Thu Nov 15 17:25:32 2018	(r340459)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 #include <sys/sysctl.h>
 
+#include <inttypes.h>
 #include <string.h>
 
 #include "systat.h"
@@ -139,11 +140,11 @@ showzarc(void)
 
 #define DO(stat, row, col, fmt) \
 	mvwprintw(wnd, row, col, fmt, stat)
-#define	R(row, stat) DO(rate.hits.stat, row, 31+1, "%3lu")
-#define	H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7lu"); \
-	DO(curstat.hits.stat, row, 31+1+5+8+8, "%12lu")
-#define	M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7lu"); \
-	DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12lu")
+#define	R(row, stat) DO(rate.hits.stat, row, 31+1, "%3"PRIu64)
+#define	H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7"PRIu64); \
+	DO(curstat.hits.stat, row, 31+1+5+8+8, "%12"PRIu64)
+#define	M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7"PRIu64); \
+	DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12"PRIu64)
 #define	E(row, stat) R(row, stat); H(row, stat); M(row, stat); 
 	E(1, arcstats);
 	E(2, arcstats_demand_data);


More information about the svn-src-all mailing list