From owner-freebsd-current@FreeBSD.ORG Sun Dec 2 15:57:52 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D4FC4A1D; Sun, 2 Dec 2012 15:57:52 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) by mx1.freebsd.org (Postfix) with ESMTP id 845AB8FC0C; Sun, 2 Dec 2012 15:57:52 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:d085:62e2:221f:26b1] (unknown [IPv6:2001:7b8:3a7:0:d085:62e2:221f:26b1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 6DE605C37; Sun, 2 Dec 2012 16:57:51 +0100 (CET) Message-ID: <50BB7A7D.9000707@FreeBSD.org> Date: Sun, 02 Dec 2012 16:57:49 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20121128 Thunderbird/18.0 MIME-Version: 1.0 To: Garrett Cooper Subject: Re: A suspicious warning in sys/boot/zfs/zfsimpl.c References: <20120703102142.6554b10e.taku@tackymt.homeip.net> <50B9E47F.6070005@FreeBSD.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Taku YAMAMOTO , freebsd-current@freebsd.org, Andriy Gapon X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Dec 2012 15:57:52 -0000 On 2012-12-02 01:37, Garrett Cooper wrote: > On Sat, Dec 1, 2012 at 3:05 AM, Andriy Gapon wrote: >> I believe that there is no actual problem there. > > It's probably bugs with clang dealing with alignment problems. Which bugs? > These warnings (and others) go largely unnoticed because of the fact > that -Werror isn't on on sys/boot. I filed kern/173932 for that and > have been grinding away on warnings for the past couple days in my > spare time -- with my local modifications sys/boot compiles with > -Werror now with gcc, but not clang. > Thanks, > -Garrett > > /store/freebsd/head/sys/boot/i386/zfsboot/zfsboot.c:101:24: error: > tentative definition of variable with internal linkage has incomplete > non-array type 'struct zfsmount' > [-Werror,-Wtentative-definition-incomplete-type] > static struct zfsmount zfsmount; > ^ > /store/freebsd/head/sys/boot/i386/zfsboot/zfsboot.c:101:15: note: > forward declaration of 'struct zfsmount' > static struct zfsmount zfsmount; > ^ This is just a programming error: struct zfsmount is declared in zfsimpl.c, but that file is included on line 151, so 50 lines after the static variable definition. Either the include should be moved up, or the definition moved down. > In file included from /store/freebsd/head/sys/boot/i386/zfsboot/zfsboot.c:151: > In file included from > /store/freebsd/head/sys/boot/i386/zfsboot/../../zfs/zfsimpl.c:38: > /store/freebsd/head/sys/boot/i386/zfsboot/../../../cddl/boot/zfs/zfssubr.c:207:9: > error: cast from 'char *' to 'zio_eck_t *' (aka 'struct zio_eck *') > increases required alignment from 1 to 4 [-Werror,-Wcast-align] > eck = (zio_eck_t *)((char *)data + size) - 1; > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Clang is right here, the alignment *is* being increased. However, on x86, there is no problem with it, so the warning can be ignored. On the other hand, if the code should be portable to alignment-sensitive arches, the code should be fixed. The same holds for all the other alignment warnings. The difference between gcc and clang is that gcc never seems to warn about alignment issues on x86. You must compile the code with a gcc targeting an alignment-sensitive arch, to get any warnings. Clang always warns, when using -Wcast-align.