From: Stephen Hemminger <sthem...@microsoft.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 <step...@networkplumber.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