summaryrefslogtreecommitdiff
path: root/net-mail/amavis-logwatch/files/redundant-argument-to-sprintf.patch
blob: 91f456afdd11aff1e6bd2aeb0c1185c745177f20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 02cf771776d2f1ad9d7872f3959e41a548adfab9 Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
Date: Thu, 24 Aug 2017 08:20:59 -0400
Subject: [PATCH 2/4] Fix redundant argument to sprintf warning.

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 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/amavis-logwatch b/amavis-logwatch
index 8972497..1aab787 100644
--- a/amavis-logwatch
+++ b/amavis-logwatch
@@ -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
             }
          }
       }
-- 
2.13.0