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: <20180710210558.20278-6-stephen@networkplumber.org>
Date:   Tue, 10 Jul 2018 14:05:32 -0700
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     netdev@...r.kernel.org
Cc:     Stephen Hemminger <sthemmin@...rosoft.com>,
        Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH v2 iproute2-next 05/31] tc/util: remove unused print functions

From: Stephen Hemminger <sthemmin@...rosoft.com>

The functions for printing rate/time/size, etc are not
used by current code. Next patch will repurpose these for
JSON format output.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 tc/tc_util.c | 49 ++++++++++++++++++-------------------------------
 tc/tc_util.h |  4 ----
 2 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index 05b6c97563b3..29bdbbff4a6e 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -307,7 +307,7 @@ int get_rate64(__u64 *rate, const char *str)
 	return 0;
 }
 
-void print_rate(char *buf, int len, __u64 rate)
+char *sprint_rate(__u64 rate, char *buf)
 {
 	extern int use_iec;
 	unsigned long kilo = use_iec ? 1024 : 1000;
@@ -325,12 +325,8 @@ void print_rate(char *buf, int len, __u64 rate)
 		rate /= kilo;
 	}
 
-	snprintf(buf, len, "%.0f%s%sbit", (double)rate, units[i], str);
-}
-
-char *sprint_rate(__u64 rate, char *buf)
-{
-	print_rate(buf, SPRINT_BSIZE-1, rate);
+	snprintf(buf, SPRINT_BSIZE-1,
+		 "%.0f%s%sbit", (double)rate, units[i], str);
 	return buf;
 }
 
@@ -361,9 +357,9 @@ int get_time(unsigned int *time, const char *str)
 	return 0;
 }
 
-
-void print_time(char *buf, int len, __u32 time)
+char *sprint_time(__u32 time, char *buf)
 {
+	const size_t len = SPRINT_BSIZE - 1;
 	double tmp = time;
 
 	if (tmp >= TIME_UNITS_PER_SEC)
@@ -372,11 +368,7 @@ void print_time(char *buf, int len, __u32 time)
 		snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
 	else
 		snprintf(buf, len, "%uus", time);
-}
 
-char *sprint_time(__u32 time, char *buf)
-{
-	print_time(buf, SPRINT_BSIZE-1, time);
 	return buf;
 }
 
@@ -455,8 +447,9 @@ void print_devname(enum output_type type, int ifindex)
 			   "dev", "%s ", ifname);
 }
 
-void print_size(char *buf, int len, __u32 sz)
+char *sprint_size(__u32 sz, char *buf)
 {
+	const size_t len = SPRINT_BSIZE - 1;
 	double tmp = sz;
 
 	if (sz >= 1024*1024 && fabs(1024*1024*rint(tmp/(1024*1024)) - sz) < 1024)
@@ -465,11 +458,7 @@ void print_size(char *buf, int len, __u32 sz)
 		snprintf(buf, len, "%gKb", rint(tmp/1024));
 	else
 		snprintf(buf, len, "%ub", sz);
-}
 
-char *sprint_size(__u32 size, char *buf)
-{
-	print_size(buf, SPRINT_BSIZE-1, size);
 	return buf;
 }
 
@@ -755,27 +744,25 @@ int get_linklayer(unsigned int *val, const char *arg)
 	return 0;
 }
 
-void print_linklayer(char *buf, int len, unsigned int linklayer)
+char *sprint_linklayer(unsigned int linklayer, char *buf)
 {
+	const size_t len = SPRINT_BSIZE - 1;
+
 	switch (linklayer) {
 	case LINKLAYER_UNSPEC:
-		snprintf(buf, len, "%s", "unspec");
-		return;
+		strlcpy(buf, "unspec", len);
+		break;
 	case LINKLAYER_ETHERNET:
-		snprintf(buf, len, "%s", "ethernet");
-		return;
+		strlcpy(buf, "ethernet", len);
+		break;
 	case LINKLAYER_ATM:
-		snprintf(buf, len, "%s", "atm");
-		return;
+		strlcpy(buf, "atm", len);
+		break;
 	default:
-		snprintf(buf, len, "%s", "unknown");
-		return;
+		strlcpy(buf, "unknown", len);
+		break;
 	}
-}
 
-char *sprint_linklayer(unsigned int linklayer, char *buf)
-{
-	print_linklayer(buf, SPRINT_BSIZE-1, linklayer);
 	return buf;
 }
 
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 64b309903c69..1690ad262351 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -84,11 +84,7 @@ int get_size_and_cell(unsigned int *size, int *cell_log, char *str);
 int get_time(unsigned int *time, const char *str);
 int get_linklayer(unsigned int *val, const char *arg);
 
-void print_rate(char *buf, int len, __u64 rate);
-void print_size(char *buf, int len, __u32 size);
 void print_qdisc_handle(char *buf, int len, __u32 h);
-void print_time(char *buf, int len, __u32 time);
-void print_linklayer(char *buf, int len, unsigned int linklayer);
 void print_devname(enum output_type type, int ifindex);
 
 char *sprint_rate(__u64 rate, char *buf);
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ