Date: Thu, 11 Sep 2014 17:59:55 -0400 From: Ryan Stone <rysto32@gmail.com> To: freebsd-net <freebsd-net@freebsd.org> Subject: [PATCH] Fix integer truncation in systat -ifstat Message-ID: <CAFMmRNwk4dQx3ZP85RWFRYELoxFCxjE5oiCbkGgb-00QnO7xpw@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
systat -ifstat currently truncates byte counters down to 32-bit integers. The following fixes the issue, but I'm not very happy with it. u_long is what the rest of our code uses for network counters, but that ends up meaning that our counters are 32-bits wide on 32-bit platforms. I could make it uint64_t but that's not very future proof. RIght now I'm leaning towards punting on the issue and using u_long as there is an awful lot of code that would have to be modified for extended byte counters to actually work on all platforms. [rstone@rstone-laptop systat]svn diff Index: ifstat.c =================================================================== --- ifstat.c (revision 271439) +++ ifstat.c (working copy) @@ -269,8 +269,8 @@ struct if_stat *ifp = NULL; struct timeval tv, new_tv, old_tv; double elapsed = 0.0; - u_int new_inb, new_outb, old_inb, old_outb = 0; - u_int new_inp, new_outp, old_inp, old_outp = 0; + u_long new_inb, new_outb, old_inb, old_outb = 0; + u_long new_inp, new_outp, old_inp, old_outp = 0; SLIST_FOREACH(ifp, &curlist, link) { /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNwk4dQx3ZP85RWFRYELoxFCxjE5oiCbkGgb-00QnO7xpw>