]> gitweb.michael.orlitzky.com - amavis-logwatch.git/commitdiff
Fix redundant argument to sprintf warning.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 24 Aug 2017 12:20:59 +0000 (08:20 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 24 Aug 2017 13:09:24 +0000 (09:09 -0400)
Perl 5.22 now warns about redundant (i.e. extra) arguments to the
sprintf function. If your format string only has two place-holders but
you pass three place-fillers, you get warned:

  Redundant argument in sprintf at ./amavis-logwatch line 1338...

The issue there was that the format string passed to sprintf was
constructed dynamically; sometimes it would contain two place-holders,
and sometimes three. Three place-fillers were always passed, so when
only two place-holders were used, the warning would be thrown. This was
fixed by testing whether or not there are two or three place-holders,
and passing the appropriate number of place-fillers.

amavis-logwatch

index 89724973fde54016a9ca601c419c24b51b705cc2..1aab7871d2b7e83bb2cf067f5c11a693d65a499d 100644 (file)
@@ -1334,8 +1334,17 @@ sub print_summary_report (\@) {
                      $$divisor == $Totals{$keyname} ? 100.00 : $Totals{$keyname} * 100 / $$divisor;
             }
             else {
-               push @{$lines[$cur_level]}, 
-                  sprintf "$fmt  %-23s $extra\n", $total, $desc, commify ($Totals{$keyname});
+               my $new_line;
+               if ($extra eq '') {
+                   $new_line = sprintf("$fmt  %-23s \n", $total, $desc);
+               }
+               else {
+                   $new_line = sprintf("$fmt  %-23s $extra\n",
+                                       $total,
+                                       $desc,
+                                       commify ($Totals{$keyname}));
+               }
+               push @{$lines[$cur_level]}, $new_line
             }
          }
       }