From: Stephen Hemminger Subject: [PATCH v2 iproute2-next 16/31] tc/util: allow signed value for time Date: Tue, 10 Jul 2018 14:05:43 -0700 Message-ID: <20180710210558.20278-17-stephen@networkplumber.org> References: <20180710210558.20278-1-stephen@networkplumber.org> Cc: Stephen Hemminger , Stephen Hemminger To: netdev@vger.kernel.org Return-path: Received: from mail-pf0-f169.google.com ([209.85.192.169]:38242 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732563AbeGJVOx (ORCPT ); Tue, 10 Jul 2018 17:14:53 -0400 Received: by mail-pf0-f169.google.com with SMTP id x13-v6so6985399pfh.5 for ; Tue, 10 Jul 2018 14:14:00 -0700 (PDT) In-Reply-To: <20180710210558.20278-1-stephen@networkplumber.org> Sender: netdev-owner@vger.kernel.org List-ID: From: Stephen Hemminger The codel algorithm wants a signed value for time when outputting values. Allow it for other uses as well. Signed-off-by: Stephen Hemminger --- 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