From: Phil Sutter <phil@nwl•cc>
To: Stephen Hemminger <stephen@networkplumber•org>
Cc: netdev@vger•kernel.org
Subject: [iproute PATCH v3 1/6] ss: Make struct tcpstat fields 'timer' and 'timeout' unsigned
Date: Thu, 24 Aug 2017 11:41:26 +0200 [thread overview]
Message-ID: <20170824094131.2963-2-phil@nwl.cc> (raw)
In-Reply-To: <20170824094131.2963-1-phil@nwl.cc>
Both 'timer' and 'timeout' variables of struct tcpstat are either
scanned as unsigned values from /proc/net/tcp{,6} or copied from
'idiag_timer' and 'idiag_expries' fields of struct inet_diag_msg, which
itself are unsigned. Therefore they may be unsigned as well, which
eliminates the need to check for negative values.
Signed-off-by: Phil Sutter <phil@nwl•cc>
---
misc/ss.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 34c6da5443642..c41d5169aba52 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -697,8 +697,8 @@ struct dctcpstat {
struct tcpstat {
struct sockstat ss;
- int timer;
- int timeout;
+ unsigned int timer;
+ unsigned int timeout;
int probes;
char cong_alg[16];
double rto, ato, rtt, rttvar;
@@ -869,13 +869,11 @@ static void sock_addr_print(const char *addr, char *delim, const char *port,
sock_addr_print_width(addr_width, addr, delim, serv_width, port, ifname);
}
-static const char *print_ms_timer(int timeout)
+static const char *print_ms_timer(unsigned int timeout)
{
static char buf[64];
int secs, msecs, minutes;
- if (timeout < 0)
- timeout = 0;
secs = timeout/1000;
minutes = secs/60;
secs = secs%60;
--
2.13.1
next prev parent reply other threads:[~2017-08-24 9:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 9:41 [iproute PATCH v3 0/6] Covscan: Misc fixes Phil Sutter
2017-08-24 9:41 ` Phil Sutter [this message]
2017-08-24 9:41 ` [iproute PATCH v3 2/6] ss: Make sure scanned index value to unix_state_map is sane Phil Sutter
2017-08-24 9:41 ` [iproute PATCH v3 3/6] netem/maketable: Check return value of fscanf() Phil Sutter
2017-08-24 9:41 ` [iproute PATCH v3 4/6] lib/bpf: Check return value of write() Phil Sutter
2017-08-24 9:41 ` [iproute PATCH v3 5/6] lib/fs: Fix and simplify make_path() Phil Sutter
2017-08-24 9:41 ` [iproute PATCH v3 6/6] lib/libnetlink: Don't pass NULL parameter to memcpy() Phil Sutter
2017-08-24 22:29 ` Stephen Hemminger
2017-08-24 22:30 ` [iproute PATCH v3 0/6] Covscan: Misc fixes Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170824094131.2963-2-phil@nwl.cc \
--to=phil@nwl$(echo .)cc \
--cc=netdev@vger$(echo .)kernel.org \
--cc=stephen@networkplumber$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox