[lcov/f16] Fix gcc 4.7 compat & opening files containing '<'

Daniel P. Berrange berrange at fedoraproject.org
Mon Mar 12 11:31:39 UTC 2012


commit 3183bab0e6056924d0d15175ddcb500803f0e349
Author: Daniel P. Berrange <berrange at redhat.com>
Date:   Mon Mar 12 11:14:15 2012 +0000

    Fix gcc 4.7 compat & opening files containing '<'

 lcov-1.9-gcc-compat-4.7.patch |   22 ++++++
 lcov-1.9-three-arg-open.patch |  157 +++++++++++++++++++++++++++++++++++++++++
 lcov.spec                     |   10 +++-
 3 files changed, 188 insertions(+), 1 deletions(-)
---
diff --git a/lcov-1.9-gcc-compat-4.7.patch b/lcov-1.9-gcc-compat-4.7.patch
new file mode 100644
index 0000000..56460c8
--- /dev/null
+++ b/lcov-1.9-gcc-compat-4.7.patch
@@ -0,0 +1,22 @@
+diff -rup lcov-1.9.orig/bin/geninfo lcov-1.9.new/bin/geninfo
+--- lcov-1.9.orig/bin/geninfo	2010-08-06 12:05:17.000000000 +0100
++++ lcov-1.9.new/bin/geninfo	2012-03-12 10:59:11.253999711 +0000
+@@ -63,6 +63,7 @@ our $lcov_url		= "http://ltp.sourceforge
+ our $gcov_tool		= "gcov";
+ our $tool_name		= basename($0);
+ 
++our $GCOV_VERSION_4_7_0	= 0x40700;
+ our $GCOV_VERSION_3_4_0	= 0x30400;
+ our $GCOV_VERSION_3_3_0	= 0x30300;
+ our $GCNO_FUNCTION_TAG	= 0x01000000;
+@@ -2903,6 +2904,10 @@ sub read_gcno_function_record(*$$$$)
+ 	graph_expect("function record");
+ 	# Skip ident and checksum
+ 	graph_skip($handle, 8, "function ident and checksum") or return undef;
++	if ($gcov_version >= $GCOV_VERSION_4_7_0) {
++	    # Skip extra word added by android 4.4.0 / gcc >= 4.7 toolchains.
++	    graph_skip($handle, 4, "android_4_4_0 extra word");
++	}
+ 	# Read function name
+ 	graph_expect("function name");
+ 	$function = read_gcno_string($handle, $big_endian);
diff --git a/lcov-1.9-three-arg-open.patch b/lcov-1.9-three-arg-open.patch
new file mode 100644
index 0000000..9a748ba
--- /dev/null
+++ b/lcov-1.9-three-arg-open.patch
@@ -0,0 +1,157 @@
+diff -rup lcov-1.9.orig/bin/geninfo lcov-1.9.new/bin/geninfo
+--- lcov-1.9.orig/bin/geninfo	2012-03-12 11:11:31.837992625 +0000
++++ lcov-1.9.new/bin/geninfo	2012-03-12 11:11:00.721000276 +0000
+@@ -424,7 +424,7 @@ if (defined($output_filename) && ($outpu
+ 	# Initially create output filename, data is appended
+ 	# for each data file processed
+ 	local *DUMMY_HANDLE;
+-	open(DUMMY_HANDLE, ">$output_filename")
++	open(DUMMY_HANDLE, ">", $output_filename)
+ 		or die("ERROR: cannot create $output_filename!\n");
+ 	close(DUMMY_HANDLE);
+ 
+@@ -906,7 +906,7 @@ sub process_dafile($$)
+ 		else
+ 		{
+ 			# Append to output file
+-			open(INFO_HANDLE, ">>$output_filename")
++			open(INFO_HANDLE, ">>", $output_filename)
+ 				or die("ERROR: cannot write to ".
+ 				       "$output_filename!\n");
+ 		}
+@@ -914,7 +914,7 @@ sub process_dafile($$)
+ 	else
+ 	{
+ 		# Open .info file for output
+-		open(INFO_HANDLE, ">$da_filename.info")
++		open(INFO_HANDLE, ">", "$da_filename.info")
+ 			or die("ERROR: cannot create $da_filename.info!\n");
+ 	}
+ 
+@@ -1267,7 +1267,7 @@ sub solve_ambiguous_match($$$)
+ 	{
+ 
+ 		# Compare file contents
+-		open(SOURCE, $filename)
++		open(SOURCE, "<", $filename)
+ 			or die("ERROR: cannot read $filename!\n");
+ 
+ 		$no_match = 0;
+@@ -1337,7 +1337,7 @@ sub read_gcov_header($)
+ 	my $object;
+ 	local *INPUT;
+ 
+-	if (!open(INPUT, $_[0]))
++	if (!open(INPUT, "<", $_[0]))
+ 	{
+ 		if ($ignore_errors[$ERROR_GCOV])
+ 		{
+@@ -1489,7 +1489,7 @@ sub read_gcov_file($)
+ 	my $last_line = 0;
+ 	local *INPUT;
+ 
+-	if (!open(INPUT, $filename)) {
++	if (!open(INPUT, "<", $filename)) {
+ 		if ($ignore_errors[$ERROR_GCOV])
+ 		{
+ 			warn("WARNING: cannot read $filename!\n");
+@@ -1669,7 +1669,7 @@ sub get_gcov_version()
+ 	my $version_string;
+ 	my $result;
+ 
+-	open(GCOV_PIPE, "$gcov_tool -v |")
++	open(GCOV_PIPE, "-|", "$gcov_tool -v")
+ 		or die("ERROR: cannot retrieve gcov version!\n");
+ 	$version_string = <GCOV_PIPE>;
+ 	close(GCOV_PIPE);
+@@ -1757,12 +1757,12 @@ sub system_no_output($@)
+ 	local *OLD_STDOUT;
+ 
+ 	# Save old stdout and stderr handles
+-	($mode & 1) && open(OLD_STDOUT, ">>&STDOUT");
+-	($mode & 2) && open(OLD_STDERR, ">>&STDERR");
++	($mode & 1) && open(OLD_STDOUT, ">>&", "STDOUT");
++	($mode & 2) && open(OLD_STDERR, ">>&", "STDERR");
+ 
+ 	# Redirect to /dev/null
+-	($mode & 1) && open(STDOUT, ">/dev/null");
+-	($mode & 2) && open(STDERR, ">/dev/null");
++	($mode & 1) && open(STDOUT, ">", "/dev/null");
++	($mode & 2) && open(STDERR, ">", "/dev/null");
+  
+ 	system(@_);
+ 	$result = $?;
+@@ -1772,8 +1772,8 @@ sub system_no_output($@)
+ 	($mode & 2) && close(STDERR);
+ 
+ 	# Restore old handles
+-	($mode & 1) && open(STDOUT, ">>&OLD_STDOUT");
+-	($mode & 2) && open(STDERR, ">>&OLD_STDERR");
++	($mode & 1) && open(STDOUT, ">>&", "OLD_STDOUT");
++	($mode & 2) && open(STDERR, ">>&", "OLD_STDERR");
+  
+ 	return $result;
+ }
+@@ -1794,7 +1794,7 @@ sub read_config($)
+ 	my $value;
+ 	local *HANDLE;
+ 
+-	if (!open(HANDLE, "<$filename"))
++	if (!open(HANDLE, "<", $filename))
+ 	{
+ 		warn("WARNING: cannot read configuration file $filename\n");
+ 		return undef;
+@@ -1866,7 +1866,7 @@ sub get_exclusion_data($)
+ 	my $flag = 0;
+ 	local *HANDLE;
+ 
+-	if (!open(HANDLE, "<$filename")) {
++	if (!open(HANDLE, "<", $filename)) {
+ 		warn("WARNING: could not open $filename\n");
+ 		return undef;
+ 	}
+@@ -2072,7 +2072,7 @@ sub process_graphfile($$)
+ 		else
+ 		{
+ 			# Append to output file
+-			open(INFO_HANDLE, ">>$output_filename")
++			open(INFO_HANDLE, ">>", $output_filename)
+ 				or die("ERROR: cannot write to ".
+ 				       "$output_filename!\n");
+ 		}
+@@ -2080,7 +2080,7 @@ sub process_graphfile($$)
+ 	else
+ 	{
+ 		# Open .info file for output
+-		open(INFO_HANDLE, ">$graph_filename.info")
++		open(INFO_HANDLE, ">", "$graph_filename.info")
+ 			or die("ERROR: cannot create $graph_filename.info!\n");
+ 	}
+ 
+@@ -2544,7 +2544,7 @@ sub read_bb($$)
+ 	my $graph;
+ 	local *HANDLE;
+ 
+-	open(HANDLE, "<$bb_filename") or goto open_error;
++	open(HANDLE, "<", $bb_filename) or goto open_error;
+ 	binmode(HANDLE);
+ 	while (!eof(HANDLE)) {
+ 		$value = read_bb_value(*HANDLE, "data word");
+@@ -2721,7 +2721,7 @@ sub read_bbg($$)
+ 	my $graph;
+ 	local *HANDLE;
+ 
+-	open(HANDLE, "<$bbg_filename") or goto open_error;
++	open(HANDLE, "<", $bbg_filename) or goto open_error;
+ 	binmode(HANDLE);
+ 	# Read magic
+ 	$word = read_bbg_value(*HANDLE, "file magic");
+@@ -2959,7 +2959,7 @@ sub read_gcno($$)
+ 	my $graph;
+ 	local *HANDLE;
+ 
+-	open(HANDLE, "<$gcno_filename") or goto open_error;
++	open(HANDLE, "<", $gcno_filename) or goto open_error;
+ 	binmode(HANDLE);
+ 	# Read magic
+ 	$word = read_gcno_word(*HANDLE, "file magic");
diff --git a/lcov.spec b/lcov.spec
index 6cab489..454951f 100644
--- a/lcov.spec
+++ b/lcov.spec
@@ -1,6 +1,6 @@
 Name: lcov
 Version: 1.9
-Release: 1%{?dist}
+Release: 2%{?dist}
 
 Summary: LTP GCOV extension code coverage tool
 Group: Development/Tools
@@ -8,6 +8,8 @@ License: GPLv2+
 
 URL: http://ltp.sourceforge.net/coverage/lcov.php
 Source0: http://downloads.sourceforge.net/ltp/lcov-%{version}.tar.gz
+Patch1: %{name}-%{version}-gcc-compat-4.7.patch
+Patch2: %{name}-%{version}-three-arg-open.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch: noarch
@@ -24,6 +26,8 @@ HTML output and support for large projects.
 
 %prep
 %setup -q
+%patch1 -p1
+%patch2 -p1
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -40,6 +44,10 @@ rm -rf $RPM_BUILD_ROOT
 %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/lcovrc
 
 %changelog
+* Mon Mar 12 2012 berrange <berrange at redhat.com> - 1.9-2
+- Fix compat with gcc 4.7 (rhbz #787502)
+- Replace 2 argument open with 3 argument open (rhbz #706040)
+
 * Mon Jan 30 2012 Daniel P. Berrange <berrange at redhat.com> - 1.9-1
 - Update to 1.9 release (rhbz #627576)
 


More information about the scm-commits mailing list