Subject: kern/36723: WD_SOFTBADSECT breaks kernel-build
To: None <,,>
From: Andreas Wiese <>
List: netbsd-bugs
Date: 08/02/2007 14:25:00
>Number:         36723
>Category:       kern
>Synopsis:       WD_SOFTBADSECT enabled kernel build dies with compiler warnings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 02 14:25:00 +0000 2007
>Originator:     Andreas Wiese
>Release:        NetBSD 4.99.21
	BSD-Crew Dresden
System: NetBSD 4.99.21 NetBSD 4.99.21 (SCHROEDER) #0: Fri Jun 29 14:11:21 CEST 2007 i386
Architecture: i386
Machine: i386

Hi, folks.

I tried to build a kernel with yesterday's HEAD.

When enabling 'option WD_SOFTBADSECT' the kernel build fails with the
following error message:

#   compile  SCHROEDER/wd.o
/usr/src/../obj/tooldir/bin/i386--netbsdelf-gcc -pipe -ffreestanding -fno-zero-initialized-in-bss -march=athlon -mtune=athlon -O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -Wextra -Wno-unused-parameter -fno-strict-aliasing -pipe -Di386 -I. -I/usr/src/sys/contrib/dev/ath/netbsd -I/usr/src/sys/../common/include -I/usr/src/sys/arch -I/usr/src/sys -nostdinc -DCRYPTO_MD_DES_ENC -DCRYPTO_MD_DES_CBC -DCRYPTO_MD_BF_ENC -DCRYPTO_MD_BF_CBC -DLKM -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -I/usr/src/sys/lib/libkern/../../../common/lib/libc/quad -I/usr/src/sys/lib/libkern/../../../common/lib/libc/string -I/usr/src/sys/lib/libkern/../../../common/lib/libc/arch/i386/string -I/usr/src/sys/dist/pf -I/usr/src/sys/dist/ipf -c /usr/src/sys/dev/ata/wd.c
cc1: warnings being treated as errors
/usr/src/sys/dev/ata/wd.c: In function 'wdioctl':
/usr/src/sys/dev/ata/wd.c:1206: warning: pointer of type 'void *' used in arithmetic

*** Failed target:  wd.o

Reason for this failure is a line stating

	laddr += sizeof(*dbs);

where laddr is a (void*) pointer and dbs is of type (struct disk_badsectors*).
echo "options WD_SOFTBADSECT" >> KERNELCONF and compile
--- src/sys/dev/ata/wd.c.orig	2007-08-02 15:16:15.000000000 +0200
+++ src/sys/dev/ata/wd.c	2007-08-02 15:16:47.000000000 +0200
@@ -1203,7 +1203,7 @@
 			available -= sizeof(*dbs);
 			copyout(dbs, laddr, sizeof(*dbs));
-			laddr += sizeof(*dbs);
+			laddr = (char *)laddr + sizeof(*dbs);

Unnützes Wissen (»neon«, 11/04):
 16. Die Kontinentaldrift kann man live auf
     beobachten.  Das Bild aktualisiert sich einmal im Jahr.