Then that's not what I based my patch on - somebody else snuck in those floats. I tested on rc1, which I thought was current at the time (or at least was the latest tarball at the time).
My code, which I tested quite a bit, is: static int _percent( unsigned long long value, unsigned long long total ) { /* avoid division by zero */ if (total == 0) return 0; float pct = (value * 100.) / total; pct += 0.5; /* rounding */ return (int) pct; } Steve -----Original Message----- From: Dave Shield [mailto:d.t.shi...@liverpool.ac.uk] Sent: Thursday, September 22, 2011 2:39 PM To: Niels Baggesen; Steve Friedl Cc: Net-SNMP coders Subject: Re: RFV: Disk calculation overflow On 22 September 2011 22:21, Steve Friedl <st...@unixwiz.net> wrote: > No, the variable it's dividing is long long - the missing dot was an > error in posting the patch (though I did all the testing with the right way). Errr... no. >From the 5.7.1.rc3 tarball: static int _percent( unsigned long long value, unsigned long long total ) { float v=value, t=total, pct; /* avoid division by zero */ if (total == 0) return 0; pct = (v*100)/t; /* Calculate percentage using floating point arithmetic, to avoid overflow errors */ pct += 0.5; /* rounding */ return (int)pct; } 'v*100' is float times integer, so surely the result should be float, as required? Dave ---------------------------------------------------------------------------- -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders