[cifs-utils/f16] Fix up some -D_FORTIFY_SOURCE=2 warnings

Jeff Layton jlayton at fedoraproject.org
Thu Apr 19 01:58:24 UTC 2012


commit 69a896e124e2c9d4e364b6a20619560adb5f6f36
Author: Jeff Layton <jlayton at redhat.com>
Date:   Wed Apr 18 21:57:59 2012 -0400

    Fix up some -D_FORTIFY_SOURCE=2 warnings
    
    ...so the package will build with -Werror.
    
    Signed-off-by: Jeff Layton <jlayton at redhat.com>

 ...s-fix-up-some-D_FORTIFY_SOURCE-2-warnings.patch |   72 ++++++++++++++++++++
 cifs-utils.spec                                    |    3 +
 2 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/0001-mount.cifs-fix-up-some-D_FORTIFY_SOURCE-2-warnings.patch b/0001-mount.cifs-fix-up-some-D_FORTIFY_SOURCE-2-warnings.patch
new file mode 100644
index 0000000..8ca3b26
--- /dev/null
+++ b/0001-mount.cifs-fix-up-some-D_FORTIFY_SOURCE-2-warnings.patch
@@ -0,0 +1,72 @@
+From 900875dbda261dd8a9283bdda3c3dbe551fe0f7c Mon Sep 17 00:00:00 2001
+From: Jeff Layton <jlayton at samba.org>
+Date: Wed, 18 Apr 2012 21:41:05 -0400
+Subject: [PATCH] mount.cifs: fix up some -D_FORTIFY_SOURCE=2 warnings
+
+...and add -D_FORTIFY_SOURCE=2 to the default $CFLAGS.
+
+Signed-off-by: Jeff Layton <jlayton at samba.org>
+---
+ Makefile.am  |    2 +-
+ mount.cifs.c |   10 ++++++----
+ mtab.c       |    4 +++-
+ 3 files changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index d95142a..05729ca 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-AM_CFLAGS = -Wall -Wextra -Werror
++AM_CFLAGS = -Wall -Wextra -Werror -D_FORTIFY_SOURCE=2
+ ACLOCAL_AMFLAGS = -I aclocal
+ 
+ root_sbindir = $(ROOTSBINDIR)
+diff --git a/mount.cifs.c b/mount.cifs.c
+index f0b073e..4f1ea40 100644
+--- a/mount.cifs.c
++++ b/mount.cifs.c
+@@ -928,9 +928,9 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
+ 				}
+ 			} else {
+ 				/* domain/username%password */
+-				const int max = MAX_DOMAIN_SIZE +
+-						MAX_USERNAME_SIZE +
+-						MOUNT_PASSWD_SIZE + 2;
++				const unsigned int max = MAX_DOMAIN_SIZE +
++							 MAX_USERNAME_SIZE +
++							 MOUNT_PASSWD_SIZE + 2;
+ 				if (strnlen(value, max + 1) >= max + 1) {
+ 					fprintf(stderr, "username too long\n");
+ 					return EX_USAGE;
+@@ -1603,8 +1603,10 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp
+ 	mountent.mnt_passno = 0;
+ 	rc = addmntent(pmntfile, &mountent);
+ 	if (rc) {
++		int ignore __attribute__((unused));
++
+ 		fprintf(stderr, "unable to add mount entry to mtab\n");
+-		ftruncate(fd, statbuf.st_size);
++		ignore = ftruncate(fd, statbuf.st_size);
+ 		rc = EX_FILEIO;
+ 	}
+ 	tmprc = my_endmntent(pmntfile, statbuf.st_size);
+diff --git a/mtab.c b/mtab.c
+index de545b7..3d42ac0 100644
+--- a/mtab.c
++++ b/mtab.c
+@@ -271,8 +271,10 @@ my_endmntent(FILE *stream, off_t size)
+ 
+ 	/* truncate file back to "size" -- best effort here */
+ 	if (rc) {
++		int ignore __attribute__((unused));
++
+ 		rc = errno;
+-		ftruncate(fd, size);
++		ignore = ftruncate(fd, size);
+ 	}
+ 
+ 	endmntent(stream);
+-- 
+1.7.7.6
+
diff --git a/cifs-utils.spec b/cifs-utils.spec
index 03462ac..a607e02 100644
--- a/cifs-utils.spec
+++ b/cifs-utils.spec
@@ -12,6 +12,7 @@ URL:            http://linux-cifs.samba.org/cifs-utils/
 BuildRoot:      %{_tmppath}/%{name}-%{version}%{pre_release}-%{release}-root-%(%{__id_u} -n)
 
 Source0:        ftp://ftp.samba.org/pub/linux-cifs/cifs-utils/%{name}-%{version}%{pre_release}.tar.bz2
+Patch0:         0001-mount.cifs-fix-up-some-D_FORTIFY_SOURCE-2-warnings.patch
 
 BuildRequires:  libcap-ng-devel libtalloc-devel krb5-devel keyutils-libs-devel autoconf automake samba-winbind-devel
 Requires:       keyutils
@@ -26,6 +27,7 @@ file system.
 
 %prep
 %setup -q -n %{name}-%{version}%{pre_release}
+%patch0 -p1
 
 %build
 %configure --prefix=/usr
@@ -57,6 +59,7 @@ rm -rf %{buildroot}
 %changelog
 * Wed Apr 18 2012 Jeff Layton <jlayton at redhat.com> 5.4-1
 - update to 5.4
+- add patch to fix up more warnings
 
 * Mon Mar 19 2012 Jeff Layton <jlayton at redhat.com> 5.3-2
 - fix tests for strtoul success (bz# 800621)


More information about the scm-commits mailing list