From root@barfooze.de  Sat Aug 31 15:21:05 2013
Return-Path: <root@barfooze.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 43BDEE70
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 31 Aug 2013 15:21:05 +0000 (UTC)
	(envelope-from root@barfooze.de)
Received: from furnace.wzff.de (furnace.wzff.de [176.9.216.40])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 025DA2705
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 31 Aug 2013 15:21:05 +0000 (UTC)
Received: from root by furnace.wzff.de with local (Exim 4.80.1 (FreeBSD))
	(envelope-from <root@barfooze.de>)
	id 1VFmrz-000PMc-RP
	for FreeBSD-gnats-submit@freebsd.org; Sat, 31 Aug 2013 17:13:47 +0200
Message-Id: <E1VFmrz-000PMc-RP@furnace.wzff.de>
Date: Sat, 31 Aug 2013 17:13:47 +0200
From: Moritz Wilhelmy <mw@wzff.de>
Reply-To: Moritz Wilhelmy <mw@wzff.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: 9.2-RELENG kernel build with clang fails in vfs
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>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:  Sun Sep  1 14:00:00 UTC 2013
>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:

From: Moritz Wilhelmy <moritz@barfooze.de>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/181710: 9.2-RELENG kernel build with clang fails in vfs
Date: Sun, 1 Sep 2013 15:55:52 +0200

 Here's another:
 
 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/nfsserver/nfs_serv.c
 /usr/src/sys/nfsserver/nfs_serv.c:3695:2: error: expression result unused [-Werror,-Wunused-value]
         VFS_STATFS(vp->v_mount, &sb);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/sys/mount.h:743:2: note: expanded from macro 'VFS_STATFS'
         _rc; })
         ^~~
 1 error generated.
 *** [nfs_serv.o] Error code 1
 
 Stop in /pool/obj/usr/src/sys/JAILHOST.
 *** [buildkernel] Error code 1
 
 Stop in /usr/src.
 *** [buildkernel] Error code 1
 
 Stop in /usr/src.
 
 
 I'm sure there's more. I think it might be good to fix these before 9.2?
>Unformatted:
