Skip to content

Commit 9753d5c

Browse files
committed
lcov: Fix output on stderr for --summary
Some functions of lcov erroneously print informational output to stderr instead of stdout as expected. Fix this by inverting the "to_file" logic in lcov to a "data_stdout" logic. Affected functions are --summary, --reset and --list. Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent 25f5d38 commit 9753d5c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

bin/lcov

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ our $convert_filenames; # If set, convert filenames when applying diff
163163
our $strip; # If set, strip leading directories when applying diff
164164
our $temp_dir_name; # Name of temporary directory
165165
our $cwd = `pwd`; # Current working directory
166-
our $to_file; # If set, indicates that output is written to a file
166+
our $data_stdout; # If set, indicates that data is written to stdout
167167
our $follow; # If set, indicates that find shall follow links
168168
our $diff_path = ""; # Path removed from tracefile when applying diff
169169
our $base_directory; # Base directory (cwd of gcc during compilation)
@@ -387,11 +387,11 @@ if (@ARGV && !($extract || $remove || $diff || @opt_summary))
387387
}
388388

389389
# Check for output filename
390-
$to_file = ($output_filename && ($output_filename ne "-"));
390+
$data_stdout = !($output_filename && ($output_filename ne "-"));
391391

392392
if ($capture)
393393
{
394-
if (!$to_file)
394+
if ($data_stdout)
395395
{
396396
# Option that tells geninfo to write to stdout
397397
$output_filename = "-";
@@ -406,6 +406,7 @@ if (!$from_package && !@directory && ($capture || $reset)) {
406406
# Check for requested functionality
407407
if ($reset)
408408
{
409+
$data_stdout = 0;
409410
# Differentiate between user space and kernel reset
410411
if (@directory)
411412
{
@@ -455,6 +456,7 @@ elsif ($extract)
455456
}
456457
elsif ($list)
457458
{
459+
$data_stdout = 0;
458460
list();
459461
}
460462
elsif ($diff)
@@ -470,6 +472,7 @@ elsif ($diff)
470472
}
471473
elsif (@opt_summary)
472474
{
475+
$data_stdout = 0;
473476
($ln_overall_found, $ln_overall_hit,
474477
$fn_overall_found, $fn_overall_hit,
475478
$br_overall_found, $br_overall_hit) = summary();
@@ -1456,7 +1459,7 @@ sub info(@)
14561459
if (!$quiet)
14571460
{
14581461
# Print info string
1459-
if ($to_file)
1462+
if (!$data_stdout)
14601463
{
14611464
printf(@_)
14621465
}
@@ -2645,7 +2648,7 @@ sub add_traces()
26452648
}
26462649

26472650
# Write combined data
2648-
if ($to_file)
2651+
if (!$data_stdout)
26492652
{
26502653
info("Writing data to $output_filename\n");
26512654
open(INFO_HANDLE, ">", $output_filename)
@@ -2875,7 +2878,7 @@ sub extract()
28752878
}
28762879

28772880
# Write extracted data
2878-
if ($to_file)
2881+
if (!$data_stdout)
28792882
{
28802883
info("Extracted $extracted files\n");
28812884
info("Writing data to $output_filename\n");
@@ -2931,7 +2934,7 @@ sub remove()
29312934
}
29322935

29332936
# Write data
2934-
if ($to_file)
2937+
if (!$data_stdout)
29352938
{
29362939
info("Deleted $removed files\n");
29372940
info("Writing data to $output_filename\n");
@@ -4065,7 +4068,7 @@ sub diff()
40654068
"unchanged.\n");
40664069

40674070
# Write data
4068-
if ($to_file)
4071+
if (!$data_stdout)
40694072
{
40704073
info("Writing data to $output_filename\n");
40714074
open(INFO_HANDLE, ">", $output_filename)

0 commit comments

Comments
 (0)