From nobody@FreeBSD.org  Tue Jun  5 15:08:48 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id EA07916A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 Jun 2007 15:08:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id CAED313C447
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 Jun 2007 15:08:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l55F8man008207
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 5 Jun 2007 15:08:48 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l55F8mgt008195;
	Tue, 5 Jun 2007 15:08:48 GMT
	(envelope-from nobody)
Message-Id: <200706051508.l55F8mgt008195@www.freebsd.org>
Date: Tue, 5 Jun 2007 15:08:48 GMT
From: Ivo Vachkov<ivo.vachkov@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Wrong #endif breaks code compilation
X-Send-Pr-Version: www-3.0

>Number:         113369
>Category:       kern
>Synopsis:       Wrong #endif breaks code compilation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 05 15:10:02 GMT 2007
>Closed-Date:    Tue Jun 05 18:56:16 GMT 2007
>Last-Modified:  Tue Jun 05 18:56:16 GMT 2007
>Originator:     Ivo Vachkov
>Release:        FreeBSD 7-CURRENT
>Organization:
InfoWeapons Corp
>Environment:
ivo-void64:~> uname -a
FreeBSD void64.unilans.net 7.0-CURRENT FreeBSD 7.0-CURRENT #1: Tue Jun  5 16:44:30 EEST 2007     ivo@void64.unilans.net:/usr/obj/usr/src/sys/64  amd64
ivo-void64:~>                                                                 
>Description:
make buildkernel KERNCONF=$KERNEL_FILE ends with the following error:

cc -c -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99  -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -mcmodel=kernel -mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow  -msoft-float -fno-asynchronous-unwind-tables -ffreestanding   /usr/src/sys/kern/kern_mutex.c
/usr/src/sys/kern/kern_mutex.c: In function '_mtx_lock_spin_failed':
/usr/src/sys/kern/kern_mutex.c:496: warning: no previous prototype for '_thread_lock_flags'
/usr/src/sys/kern/kern_mutex.c:539: warning: no previous prototype for 'thread_lock_block'
/usr/src/sys/kern/kern_mutex.c:553: warning: no previous prototype for 'thread_lock_unblock'
/usr/src/sys/kern/kern_mutex.c:562: warning: no previous prototype for 'thread_lock_set'
/usr/src/sys/kern/kern_mutex.c:580: warning: no previous prototype for '_mtx_unlock_sleep'
/usr/src/sys/kern/kern_mutex.c:759: warning: no previous prototype for 'mtx_sysinit'
/usr/src/sys/kern/kern_mutex.c:773: warning: no previous prototype for 'mtx_init'
/usr/src/sys/kern/kern_mutex.c:817: warning: no previous prototype for 'mtx_destroy'
/usr/src/sys/kern/kern_mutex.c:846: warning: no previous prototype for 'mutex_init'
/usr/src/sys/kern/kern_mutex.c:864: error: expected declaration or statement at end of input
*** Error code 1

>How-To-Repeat:
try to build without 'options SMP' and /usr/src/sys/kern/kern_mutex.c with following version:

#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/kern/kern_mutex.c,v 1.191 2007/06/04 23:51:43 jeff Exp $");

>Fix:
proposed fix is attached as patch

Patch attached with submission follows:

--- /usr/src/sys/kern/kern_mutex.c	Tue Jun  5 02:51:43 2007
+++ kern_mutex.c	Tue Jun  5 17:03:19 2007
@@ -439,12 +439,14 @@
 	/* If the mutex is unlocked, try again. */
 	if (td == NULL)
 		return;
+
 #ifdef SMP
 	printf( "spin lock %p (%s) held by %p (tid %d) too long\n",
 	    m, m->lock_object.lo_name, td, td->td_tid);
 #ifdef WITNESS
 	witness_display_spinlock(&m->lock_object, td);
 #endif
+#endif
 	panic("spin lock held too long");
 }
 
@@ -489,7 +491,6 @@
 	lock_profile_obtain_lock_success(&m->lock_object, contested,	
 	    waittime, (file), (line));
 }
-#endif /* SMP */
 
 void
 _thread_lock_flags(struct thread *td, int opts, const char *file, int line)


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Tue Jun 5 18:54:58 UTC 2007 
State-Changed-Why:  
It's been fixed already in kern_mutex.c,v 1.192. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113369 
>Unformatted:
