Skip to content

Commit f9d8079

Browse files
committed
lcov: Fix warning when specifying --rc
Current Perl versions report the following warning when using the --rc option of lcov: lcov: Use of each() on hash after insertion without resetting hash iterator results in undefined behavior Fix this warning by not modifying the hash variable that is being iterated on. Also add the missing whitespace fix-up of --rc parameters to genhtml. Reported-by: Maarten Hoes <[email protected]> Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent 2a634f6 commit f9d8079

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

bin/genhtml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@ GetOptions("config-file=s" => \$opt_config_file,
325325
"rc=s%" => \%opt_rc);
326326
Getopt::Long::Configure("default");
327327

328+
{
329+
# Remove spaces around rc options
330+
my %new_opt_rc;
331+
332+
while (my ($key, $value) = each(%opt_rc)) {
333+
$key =~ s/^\s+|\s+$//g;
334+
$value =~ s/^\s+|\s+$//g;
335+
336+
$new_opt_rc{$key} = $value;
337+
}
338+
%opt_rc = %new_opt_rc;
339+
}
340+
328341
# Read configuration file if available
329342
if (defined($opt_config_file)) {
330343
$config = read_config($opt_config_file);

bin/geninfo

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,17 @@ GetOptions("config-file=s" => \$opt_config_file,
281281
"rc=s%" => \%opt_rc);
282282
Getopt::Long::Configure("default");
283283

284-
# Remove spaces around rc options
285-
while (my ($key, $value) = each(%opt_rc)) {
286-
delete($opt_rc{$key});
284+
{
285+
# Remove spaces around rc options
286+
my %new_opt_rc;
287287

288-
$key =~ s/^\s+|\s+$//g;
289-
$value =~ s/^\s+|\s+$//g;
288+
while (my ($key, $value) = each(%opt_rc)) {
289+
$key =~ s/^\s+|\s+$//g;
290+
$value =~ s/^\s+|\s+$//g;
290291

291-
$opt_rc{$key} = $value;
292+
$new_opt_rc{$key} = $value;
293+
}
294+
%opt_rc = %new_opt_rc;
292295
}
293296

294297
# Read configuration file if available

bin/lcov

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,17 @@ GetOptions("config-file=s" => \$opt_config_file,
220220
"rc=s%" => \%opt_rc);
221221
Getopt::Long::Configure("default");
222222

223-
# Remove spaces around rc options
224-
while (my ($key, $value) = each(%opt_rc)) {
225-
delete($opt_rc{$key});
223+
{
224+
# Remove spaces around rc options
225+
my %new_opt_rc;
226226

227-
$key =~ s/^\s+|\s+$//g;
228-
$value =~ s/^\s+|\s+$//g;
227+
while (my ($key, $value) = each(%opt_rc)) {
228+
$key =~ s/^\s+|\s+$//g;
229+
$value =~ s/^\s+|\s+$//g;
229230

230-
$opt_rc{$key} = $value;
231+
$new_opt_rc{$key} = $value;
232+
}
233+
%opt_rc = %new_opt_rc;
231234
}
232235

233236
# Read configuration file if available

0 commit comments

Comments
 (0)