From dan@kulesh.obluda.cz  Wed Jun 14 08:34:18 2006
Return-Path: <dan@kulesh.obluda.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9178A16A41A
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 Jun 2006 08:34:18 +0000 (UTC)
	(envelope-from dan@kulesh.obluda.cz)
Received: from smtp1.kolej.mff.cuni.cz (smtp1.kolej.mff.cuni.cz [195.113.24.4])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CF1B343D48
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 Jun 2006 08:34:17 +0000 (GMT)
	(envelope-from dan@kulesh.obluda.cz)
Received: from kulesh.obluda.cz (openvpn.ms.mff.cuni.cz [195.113.20.87])
	by smtp1.kolej.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k5E8YNA1078938
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 Jun 2006 10:34:25 +0200 (CEST)
	(envelope-from dan@kulesh.obluda.cz)
Received: from kulesh.obluda.cz (localhost.other [127.0.0.1] (may be forged))
	by kulesh.obluda.cz (8.13.6/8.13.6) with ESMTP id k5E8YE8g001503
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 Jun 2006 10:34:14 +0200 (CEST)
	(envelope-from dan@kulesh.obluda.cz)
Received: (from root@localhost)
	by kulesh.obluda.cz (8.13.6/8.13.6/Submit) id k5E8YDN8001502;
	Wed, 14 Jun 2006 10:34:13 +0200 (CEST)
	(envelope-from dan)
Message-Id: <200606140834.k5E8YDN8001502@kulesh.obluda.cz>
Date: Wed, 14 Jun 2006 10:34:13 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: Dan Lukes <dan@obluda.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [ PATCH ] Kernel compilation failed on specific PERFMON configuration
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         98932
>Category:       i386
>Synopsis:       [i386] [patch] Kernel compilation failed on specific PERFMON configuration
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-i386
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 14 08:40:13 GMT 2006
>Closed-Date:    Fri Feb 12 10:58:55 UTC 2010
>Last-Modified:  Fri Feb 12 10:58:55 UTC 2010
>Originator:     Dan Lukes
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
Obludarium
>Environment:
System: FreeBSD 6.1-STABLE #4: Mon May 29 15:29:58 CEST 2006 i386
sys/i386/isa/prof_machdep.c,v 1.25 2005/05/20 17:16:24 njl

>Description:
	In the sys/i386/isa/prof_machdep.c

	The variables cputime_clock_pmc_conf,cputime_clock_pmc_init,saved_gmp
 	are declared when I586_PMC_GUPROF defined, but in the actual code,
	they are used when I586_PMC_GUPROF AND PERFMON defined only.

	It cause ...
/usr/src/sys/i386/isa/prof_machdep.c:66 warning: 'cputime_clock_pmc_conf' defined but not used
/usr/src/sys/i386/isa/prof_machdep.c:67 warning: 'cputime_clock_pmc_init' defined but not used
/usr/src/sys/i386/isa/prof_machdep.c:67 warning: 'saved_gmp' defined but not used

	... warning during compilation.

	As "count warning as error" is in efect for compilation (unless
	NO_WERROR defined) the compilation will fail.

>How-To-Repeat:
	Add I586_PMC_GUPROF but no PERFMON to kernel configuration file.
	Try to compile kernel.
>Fix:

	There are several possible ways to fix it.

1. We can declare there has no reason to use I586_PMC_GUPROF without
   PERFMON, so it's administrator's error.

2. We can add __unused to variable declaration

3. We can declare variables only when used later.

	Althought [1] seems to be true, I recommend [3]:

--- sys/i386/isa/prof_machdep.c.ORIG	Wed Jun 14 10:15:18 2006
+++ sys/i386/isa/prof_machdep.c	Wed Jun 14 10:20:34 2006
@@ -62,7 +62,7 @@
 int	cputime_bias = 1;	/* initialize for locality of reference */
 
 static int	cputime_clock = CPUTIME_CLOCK_UNINITIALIZED;
-#ifdef I586_PMC_GUPROF
+#if defined(PERFMON) && defined(I586_PMC_GUPROF)
 static u_int	cputime_clock_pmc_conf = I586_PMC_GUPROF;
 static int	cputime_clock_pmc_init;
 static struct gmonparam saved_gmp;


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched  
State-Changed-By: brucec 
State-Changed-When: Thu Feb 11 17:32:47 UTC 2010 
State-Changed-Why:  
The problem was fixed in revision 1.29 of prof_machdep.c. 
It hasn't been MFC'd to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98932 
State-Changed-From-To: patched->closed  
State-Changed-By: brucec 
State-Changed-When: Fri Feb 12 10:57:49 UTC 2010 
State-Changed-Why:  
Fixed in 7.x and newer. 

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