Subject: Re: kern/36723: WD_SOFTBADSECT breaks kernel-build
To: None <gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,>
From: John Nemeth <jnemeth@victoria.tc.ca>
List: netbsd-bugs
Date: 08/02/2007 15:48:51
On Nov 18,  2:32am, Andreas Wiese wrote:
} >Number:         36723
} >Synopsis:       WD_SOFTBADSECT enabled kernel build dies with compiler warnings
} >Description:
} 
} 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:
} 
} #v+
} #   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*).
} >Fix:
} [snip]

     Could you try this fix instead, please (casting an lhs is bad form)?

diff -u -r1.343 wd.c
--- wd.c        30 Jul 2007 06:59:13 -0000      1.343
+++ wd.c        2 Aug 2007 22:42:39 -0000
@@ -1175,14 +1175,14 @@
                struct disk_badsecinfo dbsi;
                struct disk_badsectors *dbs;
                size_t available;
-               void *laddr;
+               uint8_t *laddr;

                dbsi = *(struct disk_badsecinfo *)addr;
                missing = wd->sc_bscount;
                count = 0;
                available = dbsi.dbsi_bufsize;
                skip = dbsi.dbsi_skip;
-               laddr = dbsi.dbsi_buffer;
+               laddr = (uint8_t *)dbsi.dbsi_buffer;

                /*
                 * We start this loop with the expectation that all of the

}-- End of excerpt from Andreas Wiese