From owner-freebsd-fs@FreeBSD.ORG Sun Apr 12 16:54:22 2015 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 23E1A950 for ; Sun, 12 Apr 2015 16:54:22 +0000 (UTC) Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu [18.9.25.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7BAEA7F for ; Sun, 12 Apr 2015 16:54:21 +0000 (UTC) X-AuditID: 1209190e-f79a76d000000d1b-02-552aa3361a2a Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 92.AC.03355.633AA255; Sun, 12 Apr 2015 12:54:14 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id t3CGsDVE020023; Sun, 12 Apr 2015 12:54:13 -0400 Received: from multics.mit.edu (system-low-sipb.mit.edu [18.187.2.37]) (authenticated bits=56) (User authenticated as kaduk@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id t3CGsBiO020463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 12 Apr 2015 12:54:12 -0400 Received: (from kaduk@localhost) by multics.mit.edu (8.12.9.20060308) id t3CGsAVE025545; Sun, 12 Apr 2015 12:54:10 -0400 (EDT) Date: Sun, 12 Apr 2015 12:54:10 -0400 (EDT) From: Benjamin Kaduk X-X-Sender: kaduk@multics.mit.edu To: Garrett Wollman Subject: Re: ZFS compiler warnings In-Reply-To: <21800.25526.8680.435299@khavrinen.csail.mit.edu> Message-ID: References: <21800.25526.8680.435299@khavrinen.csail.mit.edu> User-Agent: Alpine 1.10 (GSO 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsUixG6nomu2WCvU4H2vgsWxxz/ZHBg9Znya zxLAGMVlk5Kak1mWWqRvl8CVceLAJ5aCqQIVP5epNDB+5+li5OSQEDCR+LblCBOELSZx4d56 ti5GLg4hgcVMEo3Ld7FCOBsZJdZcnckI4RxikriwdAozSIuQQAOjxKe9gSA2i4C2xKr/IEWc HGwCahKP9zazQoxVlNh8ahJYvQhQzccll4FsDg5mASmJO2srQExhASWJ5VdZQCo4Bewkzjx9 BGbzCjgCHTePHWKTrcSGG0/ApogK6Eis3j8FqkZQ4uTMJ2A2s4CWxPLp21gmMArNQpKahSS1 gJFpFaNsSm6Vbm5iZk5xarJucXJiXl5qka6xXm5miV5qSukmRlCgckry7WD8elDpEKMAB6MS D++F35qhQqyJZcWVuYcYJTmYlER5Y0u1QoX4kvJTKjMSizPii0pzUosPMUpwMCuJ8M6YB5Tj TUmsrEotyodJSXOwKInzbvrBFyIkkJ5YkpqdmlqQWgSTleHgUJLgnbIQqFGwKDU9tSItM6cE Ic3EwQkynAdo+HWQGt7igsTc4sx0iPwpRkUpcd6dIAkBkERGaR5cLyyRvGIUB3pFmPcdSBUP MAnBdb8CGswENDhLBWxwSSJCSqqBkat777+XsTc+m/fLql+Q3HDjrb9NRNKbhCVXZim+nCl0 gft1yLXsvX6TWbZ6Lzex27A8hUv/szaLmtuN11vkzG++nH7Q+86ZwPgr0hd159cfb/z5wGCr mH3rj2XBs1etnaPrcOmZ/UQfl3OqTZGhJZ0sCapvK2MrP67/9veO0RPltq08lg1sYkosxRmJ hlrMRcWJAJQfKzP/AgAA Cc: freebsd-fs@freebsd.org X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2015 16:54:22 -0000 On Fri, 10 Apr 2015, Garrett Wollman wrote: > I notice on my 10.1 kernel builds warnings like the following: > > /usr/src/sys/modules/zfs/../../cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c:2855:12: warning: comparison of constant -1 with expression of type 'zfs_prop_t' is always true [-Wtautological-constant-out-of-range-compare] > if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop)) > ~~~~ ^ ~~~~~~~~~~~ > /usr/src/sys/modules/zfs/../../cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c:3810:11: warning: comparison of constant -1 with expression of type 'zfs_prop_t' is always false [-Wtautological-constant-out-of-range-compare] > if (prop == ZPROP_INVAL) { > ~~~~ ^ ~~~~~~~~~~~ > > The warnings indicate that these checks are being optimized away by > clang. The code in head is the same. Does anyone have an idea of how > this should be fixed, in a way that would be acceptable upstream? (Do > we have someone who is the "official" liaison with the OpenZFS > project?) > > My guess is that the definition of the zfs_prop_t enum itself needs to > include these two constants explicitly -- but that also has the effect > of changing the type of ZPROP_INVAL, which then means that > zpool_prop_t needs to have its own version of "invalid property" > defined, and that then requires cascading changes in a bunch of other > places. n1256.pdf lists as a "common warning" (annex I) the case where a value is assigned to a variable of enumerated type and the value is not from the same set of enumerated constants, so any assignment of ZPROP_INVAL to a variable of type zpool_prop_t should trigger a warning with the current code. (If there are no such assignments, then why are we bothering to check against it?) > The following is a minimal change that fixes the warnings in the > kernel alone (beware whitespace lossage) -- I haven't checked the > userland side: It seems like the right thing to do, to me, but I am not really a ZFS guy. -Ben