[macchanger] Build package with -Werror

thoger thoger at fedoraproject.org
Fri Jul 4 08:25:56 UTC 2014


commit 8206ac16f8d34f0c91ef0f66acc2130e6c4efbc6
Author: Tomas Hoger <thoger at redhat.com>
Date:   Fri Jul 4 10:28:00 2014 +0200

    Build package with -Werror

 macchanger-1.7.0-werror.diff |   35 +++++++++++++++++++++++++++++++++++
 macchanger.spec              |   11 +++++++++--
 2 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/macchanger-1.7.0-werror.diff b/macchanger-1.7.0-werror.diff
new file mode 100644
index 0000000..a322ff7
--- /dev/null
+++ b/macchanger-1.7.0-werror.diff
@@ -0,0 +1,35 @@
+Fix compile time warning to make it possible to build package with -Werror.
+
+main.c: In function 'random_seed':
+main.c:100:3: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
+   read (fd, &seed, sizeof(seed));
+   ^
+
+If required number of seed bytes can not be read from the random device, fall
+back to using using predictable, but frequently changing seed.  The macchanger
+does not require high quality randomness, and the predictable seed method is
+already fallback for cases when no random device is available.
+
+diff -pruN macchanger-1.7.0.orig/src/main.c macchanger-1.7.0/src/main.c
+--- macchanger-1.7.0.orig/src/main.c	2014-07-04 09:44:29.505142598 +0200
++++ macchanger-1.7.0/src/main.c	2014-07-04 10:16:32.238186470 +0200
+@@ -93,13 +93,17 @@ random_seed (void)
+ 	int            fd;
+ 	struct timeval tv;
+ 	unsigned int   seed;
++	int            have_seed = 0;
+ 
+ 	if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 ||
+ 	    (fd = open("/dev/random", O_RDONLY)) >= 0)
+ 	{
+-		read (fd, &seed, sizeof(seed));
++		have_seed = ( read (fd, &seed, sizeof(seed)) == sizeof(seed) );
+ 		close (fd);
+-	} else {
++	}
++	
++	/* Use predictable non-constant seed as fallback */
++	if (!have_seed) {
+ 		gettimeofday (&tv, NULL);
+ 		seed = (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec;
+ 	}
diff --git a/macchanger.spec b/macchanger.spec
index 68dda4b..1856023 100644
--- a/macchanger.spec
+++ b/macchanger.spec
@@ -1,6 +1,6 @@
 Name:           macchanger
 Version:        1.7.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        An utility for viewing/manipulating the MAC address of network interfaces
 Group:          Applications/System
 License:        GPLv3+
@@ -18,6 +18,8 @@ Source0:        https://github.com/alobbs/%{name}/releases/download/%{version}/%
 
 # prefer /dev/urandom as source of seed for random
 Patch1:         macchanger-1.7.0-seed-source.diff
+# fix compile time warning to make package build with -Werror
+Patch2:         macchanger-1.7.0-werror.diff
 
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -42,9 +44,11 @@ Features:
 %prep
 %setup -q
 %patch1 -p1 -b .seedsource
+%patch2 -p1 -b .werror
 
 
 %build
+CFLAGS="$RPM_OPT_FLAGS -Werror"
 %configure
 make %{?_smp_mflags} V=1
 
@@ -76,11 +80,14 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Fri Jul  4 2014 Tomas Hoger <thoger at fedoraproject.org> - 1.7.0-2
+- Build package with -Werror
+
 * Fri Jul  4 2014 Tomas Hoger <thoger at fedoraproject.org> - 1.7.0-1
 - Update to upstream 1.7.0
 - Licence change from GPLv2+ to GPLv3+
   https://github.com/alobbs/macchanger/issues/3#issuecomment-31526964
-- Upstream sources are now on github, no more signatures :-(.
+- Upstream sources are now on github, no more signatures :-(
 - Dropped patches - fixes applied upstream:
   1.6.0-dynamic-lists.diff
   1.6.0-dev-name-overflow.diff


More information about the scm-commits mailing list