kern/181710: 9.2-RELENG kernel build with clang fails in vfs

Moritz Wilhelmy mw at wzff.de
Sat Aug 31 15:30:01 UTC 2013


>Number:         181710
>Category:       kern
>Synopsis:       9.2-RELENG kernel build with clang fails in vfs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 31 15:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Moritz Wilhelmy
>Release:        FreeBSD 9.1-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD host.wzff.de 9.1-RELEASE FreeBSD 9.1-RELEASE #4 r246626: Sun Feb 10 22:00:34 UTC 2013 root@:/usr/obj/usr/src/sys/RCTL_ALTQ amd64

>Description:
	Latest 'make buildkernel' of a recently updated svn checkout
(r255094) of the 9.2-RELENG branch fails with clang due to ignored
return value of some VFS_* macros as follows:

clang -c -O2 -pipe -fno-strict-aliasing  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option  -Wno-error-tautological-compare -Wno-error-empty-body  -Wno-error-parentheses-equality -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h  -fno-omit-frame-pointer -mno-aes -mno-avx -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -Werror  /usr/src/sys/kern/vfs_mountroot.c
/usr/src/sys/kern/vfs_mountroot.c:270:2: error: expression result unused [-Werror,-Wunused-value]
        VFS_ROOT(mporoot, LK_EXCLUSIVE, &vporoot);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/sys/sys/mount.h:727:2: note: expanded from macro 'VFS_ROOT'
        _rc; })
        ^~~
1 error generated.
*** [vfs_mountroot.o] Error code 1

Stop in /pool/obj/usr/src/sys/GENERIC.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.

>How-To-Repeat:
Run "make buildkernel" using clang
	
>Fix:
Cast to (void) to explicitely ignore the return value?
The patch below at least fixes my kernel build with clang, but maybe
they should be cast to (void) in the macro definition instead, if the
macro return value is never supposed to be used.

Index: kern/vfs_mountroot.c
===================================================================
--- kern/vfs_mountroot.c	(revision 255094)
+++ kern/vfs_mountroot.c	(working copy)
@@ -267,7 +267,7 @@
 	if (mporoot != mpdevfs)
 		cache_purgevfs(mpdevfs);
 
-	VFS_ROOT(mporoot, LK_EXCLUSIVE, &vporoot);
+	(void)VFS_ROOT(mporoot, LK_EXCLUSIVE, &vporoot);
 
 	VI_LOCK(vporoot);
 	vporoot->v_iflag &= ~VI_MOUNT;
Index: kern/vfs_syscalls.c
===================================================================
--- kern/vfs_syscalls.c	(revision 255094)
+++ kern/vfs_syscalls.c	(working copy)
@@ -147,7 +147,7 @@
 		    vn_start_write(NULL, &mp, V_NOWAIT) == 0) {
 			save = curthread_pflags_set(TDP_SYNCIO);
 			vfs_msync(mp, MNT_NOWAIT);
-			VFS_SYNC(mp, MNT_NOWAIT);
+			(void)VFS_SYNC(mp, MNT_NOWAIT);
 			curthread_pflags_restore(save);
 			vn_finished_write(mp);
 		}
Index: ufs/ffs/ffs_softdep.c
===================================================================
--- ufs/ffs/ffs_softdep.c	(revision 255094)
+++ ufs/ffs/ffs_softdep.c	(working copy)
@@ -3407,7 +3407,7 @@
 		if (journal_unsuspend(ump))
 			return;
 		FREE_LOCK(&lk);
-		VFS_SYNC(mp, MNT_NOWAIT);
+		(void)VFS_SYNC(mp, MNT_NOWAIT);
 		ffs_sbupdate(ump, MNT_WAIT, 0);
 		ACQUIRE_LOCK(&lk);
 	}
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list