NetBSD Problem Report #44083

From www@NetBSD.org  Thu Nov 11 23:19:49 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id A441C63BA8D
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 11 Nov 2010 23:19:49 +0000 (UTC)
Message-Id: <20101111231949.4D2DB63BA61@www.NetBSD.org>
Date: Thu, 11 Nov 2010 23:19:49 +0000 (UTC)
From: jmosalmi@cc.hut.fi
Reply-To: jmosalmi@cc.hut.fi
To: gnats-bugs@NetBSD.org
Subject: Compiling domU kernel with PCI bus enabled fails on a compiler warning of unused variable "mode"
X-Send-Pr-Version: www-1.0

>Number:         44083
>Category:       port-xen
>Synopsis:       Compiling domU kernel with PCI bus enabled fails on a compiler warning of unused variable "mode"
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-xen-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 11 23:20:00 +0000 2010
>Closed-Date:    Fri Nov 12 02:18:38 +0000 2010
>Last-Modified:  Fri Nov 12 02:18:38 +0000 2010
>Originator:     Juho Salminen
>Release:        5.99.39
>Organization:
Home
>Environment:
NetBSD hohtokaija1.jmos.iki.fi 5.99.39 NetBSD 5.99.39 (XEN3_DOMU_HK1) #1: Thu Nov 11 23:37:33 EET 2010  fijusal@siniara.jmos.iki.fi:/usr/netbsd-current/obj/sys/arch/i386/compile/XEN3_DOMU_HK1 i386

>Description:
Building the i386 Xen domU kernel with PCI bus enabled fails
on a compiler warning when compiling mainbus.c. The warning
states that variable "mode" is declared but not used.

The variable "mode" is declared in mainbus_attach() inside a #if
NPCI > 0. It is only used afterwards if DOM0OPS is also
defined. Thus, if DOM0OPS is not defined when NPCI is non-zero,
the variable is declared but not used, causing a compiler warning
that breaks the build.

The kernel configuration I used is the following:
---
include         "arch/i386/conf/XEN3_DOMU"

# Add support for PCI busses to the XEN3_DOMU kernel
xpci* at xenbus?
pci* at xpci ?

# Now add PCI and related devices to be used by this domain
# USB Controller and Devices

# PCI USB controllers
ehci*   at pci? dev ? function ?        # Enhanced Host Controller
uhci*   at pci? dev ? function ?        # Universal Host Controller

# USB bus support
usb*    at ehci?
usb*    at uhci?

# USB Hubs
uhub*   at usb?
uhub*   at uhub? port ? configuration ? interface ?

# USB Mass Storage
umass*  at uhub? port ? configuration ? interface ?
wd*     at umass?

# SCSI bus support (for both ahc and umass)
scsibus* at scsi?

# SCSI devices
sd*     at scsibus? target ? lun ?      # SCSI disk drives
---

The compiler error is the following:
---
#   compile  XEN3_DOMU_HK1/mainbus.o
/usr/netbsd-current/src/../tools/bin/i486--netbsdelf-gcc -ffreestanding -fno-zero-initialized-in-bss -O2 -std=gnu99 -fstack-protector -Wstack-protector --param ssp-buffer-size=1 -fno-strict-aliasing -fstack-protector -Wstack-protector --param ssp-buffer-size=1 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -Werror -march=i686 -Di386 -I. -I/usr/netbsd-current/obj/sys/arch/i386/compile/XEN3_DOMU_HK1/xen-ma -I/usr/netbsd-current/src/sys/../common/include -I/usr/netbsd-current/src/sys/arch -I/usr/netbsd-current/src/sys -nostdinc -DDIAGNOSTIC -DDEBUG -DMAXPHYS=32768 -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -I/usr/netbsd-current/src/sys/lib/libkern/../../../common/lib/libc/quad -I/usr/netbsd-current/src/sys/lib/libkern/../../../common/lib/libc/string -I/usr/netbsd-current/src/sys/lib/libkern/../../../common/li
 b/libc/arch/i386/string -I/usr/netbsd-current/src/sys/dist/ipf -c /usr/netbsd-current/src/sys/arch/xen/x86/mainbus.c
cc1: warnings being treated as errors
/usr/netbsd-current/src/sys/arch/xen/x86/mainbus.c: In function 'mainbus_attach':
/usr/netbsd-current/src/sys/arch/xen/x86/mainbus.c:137: warning: unused variable 'mode'

*** Failed target:  mainbus.o
---


>How-To-Repeat:
With the configuration file shown above, attempt to compile the
kernel.

>Fix:
Wrapping the variable declaration in #ifdef DOM0OPS fixes this:

Index: mainbus.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/x86/mainbus.c,v
retrieving revision 1.12
diff -u -r1.12 mainbus.c
--- mainbus.c   7 Aug 2010 21:59:11 -0000       1.12
+++ mainbus.c   11 Nov 2010 22:44:40 -0000
@@ -133,9 +133,11 @@
 void
 mainbus_attach(device_t parent, device_t self, void *aux)
 {
+#ifdef DOM0OPS
 #if NPCI > 0
        int mode;
 #endif
+#endif
        union mainbus_attach_args mba;
 #if defined(DOM0OPS)
        int numcpus = 0;

>Release-Note:

>Audit-Trail:
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44083 CVS commit: src/sys/arch/xen/x86
Date: Fri, 12 Nov 2010 02:07:28 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Fri Nov 12 02:07:28 UTC 2010

 Modified Files:
 	src/sys/arch/xen/x86: mainbus.c

 Log Message:
 Build fix for xen domu + PCI, from Juho Salminen in PR 44083.


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.13 src/sys/arch/xen/x86/mainbus.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 12 Nov 2010 02:18:38 +0000
State-Changed-Why:
fixed, thanks


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.