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]
Date:   Tue, 10 Jul 2018 14:05:43 -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 16/31] tc/util: allow signed value for time

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

The codel algorithm wants a signed value for time when
outputting values.  Allow it for other uses as well.

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

diff --git a/tc/tc_util.c b/tc/tc_util.c
index 43a67fd13f94..3789b38773a7 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -370,7 +370,7 @@ int get_time(unsigned int *time, const char *str)
 	return 0;
 }
 
-char *sprint_time(__u32 time, char *buf)
+char *sprint_time(__s32 time, char *buf)
 {
 	const size_t len = SPRINT_BSIZE - 1;
 	double tmp = time;
@@ -380,12 +380,12 @@ char *sprint_time(__u32 time, char *buf)
 	else if (tmp >= TIME_UNITS_PER_SEC/1000)
 		snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
 	else
-		snprintf(buf, len, "%uus", time);
+		snprintf(buf, len, "%dus", time);
 
 	return buf;
 }
 
-void print_time(const char *key, const char *fmt, __u32 tm)
+void print_time(const char *key, const char *fmt, __s32 tm)
 {
 	double secs = (double)tm / TIME_UNITS_PER_SEC;
 	SPRINT_BUF(b1);
diff --git a/tc/tc_util.h b/tc/tc_util.h
index e83bb7dbcc76..23d11520eb50 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -97,7 +97,7 @@ char *sprint_rate(__u64 rate, char *buf);
 char *sprint_size(__u32 size, char *buf);
 char *sprint_qdisc_handle(__u32 h, char *buf);
 char *sprint_tc_classid(__u32 h, char *buf);
-char *sprint_time(__u32 time, char *buf);
+char *sprint_time(__s32 time, char *buf);
 char *sprint_ticks(__u32 ticks, char *buf);
 char *sprint_linklayer(unsigned int linklayer, char *buf);
 
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ