cnfsstat rounding trouble

Russ Allbery rra at stanford.edu
Sun May 23 22:44:36 UTC 2004


Christoph Biedl <cbiedl at gmx.de> writes:

> This happens with Debian sarge (INN 2.4.1, perl 5.8).
> This does not happen with Debian stable (INN 2.3.x or INN 2.4.1 compiled
> from sources, perl 5.6)
> This _might_ have also happened more than one year ago with a terribly
> deconfigured Slackware running INN 2.3.x and perl 5.8.

> Trying to reproduce this error didn't succeed however I'm quite sure that
> this problem ist related to a minor change between Perl 5.6 and 5.8.

> What actually happens:
> Looking at cnfsstat line 290 (and similar places)
> |     printf("  %.2f cycles\n", $cyclenum + $free/$len);
> the division $free/$len always results in 0 since $free <= $len and perl
> appearently uses integer division.

> How to fix:
> The C-style make-me-double '(1.0 * $free)/(1.0 * $len)' does not help, a
> workaround is to eval the variables before doing the computations:

I could have sworn I already fixed this in STABLE....

Ah, the patch is only in CURRENT.  Could you try this and let me know if
it fixes the problem?  If it doesn't, it may just be that cnfsstat needs
additional fixes along similar lines.

--- cnfsstat.in 6 Oct 2002 04:11:42 -0000       1.18
+++ cnfsstat.in 26 Dec 2003 03:28:40 -0000      1.19
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 # fixscript will replace this line with require innshellvars.pl
 
-#  $Id: cnfsstat.in,v 1.18 2002/10/06 04:11:42 vinocur Exp $
+#  $Id: cnfsstat.in,v 1.19 2003/12/26 03:28:40 rra Exp $
 # 
 #  Copyright Andreas Lamrecht 1998
 #  <Andreas.Lamprect at siemens.at>
@@ -17,6 +17,7 @@
 use vars qw($opt_l $opt_h $opt_a $opt_s);
 use Getopt::Long;
 use Math::BigInt;
+use Math::BigFloat;
 use English;
 
 my($conffile) = "$inn::pathetc/cycbuff.conf";
@@ -324,7 +325,7 @@
     my $factor = 1024;
 
     my $unit = -1;
-    my $oldscaled = $val / $base;
+    my $oldscaled = Math::BigFloat->new ($val) / $base;
     my $scaled = $oldscaled;
     while ( ( int($scaled) > 0 ) && ( $unit < $#name ) ) {
        $oldscaled = $scaled;

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.


More information about the inn-workers mailing list