Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jan 2018 05:52:39 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328252 - in head: cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/s...
Message-ID:  <201801220552.w0M5qdxP062338@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Jan 22 05:52:39 2018
New Revision: 328252
URL: https://svnweb.freebsd.org/changeset/base/328252

Log:
  MFV r328251: 8652 Tautological comparisons with ZPROP_INVAL
  
  illumos/illumos-gate@4ae5f5f06c6c2d1db8167480f7d9e3b5378ba2f2
  
  https://www.illumos.org/issues/8652:
  Clang and GCC prefer to use unsigned ints to store enums. With Clang, that
  causes tautological comparison warnings when comparing a zfs_prop_t or
  zpool_prop_t variable to the macro ZPROP_INVAL. It's likely that error
  handling code is being silently removed as a result.
  
  Reviewed by: Matthew Ahrens <mahrens@delphix.com>
  Reviewed by: Igor Kozhukhov <igor@dilos.org>
  Approved by: Gordon Ross <gwr@nexenta.com>
  Author: Alan Somers <asomers@gmail.com>

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/lib/libzfs/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Mon Jan 22 04:48:14 2018	(r328251)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Mon Jan 22 05:52:39 2018	(r328252)
@@ -441,7 +441,7 @@ add_prop_list(const char *propname, char *propval, nvl
 		 * feature@ properties and version should not be specified
 		 * at the same time.
 		 */
-		if ((prop == ZPROP_INVAL && zpool_prop_feature(propname) &&
+		if ((prop == ZPOOL_PROP_INVAL && zpool_prop_feature(propname) &&
 		    nvlist_exists(proplist, vname)) ||
 		    (prop == ZPOOL_PROP_VERSION &&
 		    prop_list_contains_feature(proplist))) {

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c	Mon Jan 22 04:48:14 2018	(r328251)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c	Mon Jan 22 05:52:39 2018	(r328252)
@@ -445,7 +445,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char 
 		const char *propname = nvpair_name(elem);
 
 		prop = zpool_name_to_prop(propname);
-		if (prop == ZPROP_INVAL && zpool_prop_feature(propname)) {
+		if (prop == ZPOOL_PROP_INVAL && zpool_prop_feature(propname)) {
 			int err;
 			char *fname = strchr(propname, '@') + 1;
 
@@ -484,7 +484,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char 
 		/*
 		 * Make sure this property is valid and applies to this type.
 		 */
-		if (prop == ZPROP_INVAL) {
+		if (prop == ZPOOL_PROP_INVAL) {
 			zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
 			    "invalid property '%s'"), propname);
 			(void) zfs_error(hdl, EZFS_BADPROP, errbuf);

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Mon Jan 22 04:48:14 2018	(r328251)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Mon Jan 22 05:52:39 2018	(r328252)
@@ -349,7 +349,7 @@ spa_prop_get(spa_t *spa, nvlist_t **nvp)
 		zprop_source_t src = ZPROP_SRC_DEFAULT;
 		zpool_prop_t prop;
 
-		if ((prop = zpool_name_to_prop(za.za_name)) == ZPROP_INVAL)
+		if ((prop = zpool_name_to_prop(za.za_name)) == ZPOOL_PROP_INVAL)
 			continue;
 
 		switch (za.za_integer_length) {
@@ -437,7 +437,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
 		zpool_prop_t prop = zpool_name_to_prop(propname);
 
 		switch (prop) {
-		case ZPROP_INVAL:
+		case ZPOOL_PROP_INVAL:
 			if (!zpool_prop_feature(propname)) {
 				error = SET_ERROR(EINVAL);
 				break;
@@ -680,7 +680,7 @@ spa_prop_set(spa_t *spa, nvlist_t *nvp)
 		    prop == ZPOOL_PROP_READONLY)
 			continue;
 
-		if (prop == ZPOOL_PROP_VERSION || prop == ZPROP_INVAL) {
+		if (prop == ZPOOL_PROP_VERSION || prop == ZPOOL_PROP_INVAL) {
 			uint64_t ver;
 
 			if (prop == ZPOOL_PROP_VERSION) {
@@ -6658,7 +6658,7 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
 		spa_feature_t fid;
 
 		switch (prop = zpool_name_to_prop(nvpair_name(elem))) {
-		case ZPROP_INVAL:
+		case ZPOOL_PROP_INVAL:
 			/*
 			 * We checked this earlier in spa_prop_validate().
 			 */

Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h	Mon Jan 22 04:48:14 2018	(r328251)
+++ head/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h	Mon Jan 22 05:52:39 2018	(r328252)
@@ -90,7 +90,9 @@ typedef enum dmu_objset_type {
  * the property table in usr/src/common/zfs/zfs_prop.c.
  */
 typedef enum {
-	ZFS_PROP_TYPE,
+	ZPROP_CONT = -2,
+	ZPROP_INVAL = -1,
+	ZFS_PROP_TYPE = 0,
 	ZFS_PROP_CREATION,
 	ZFS_PROP_USED,
 	ZFS_PROP_AVAILABLE,
@@ -183,6 +185,7 @@ extern const char *zfs_userquota_prop_prefixes[ZFS_NUM
  * the property table in usr/src/common/zfs/zpool_prop.c.
  */
 typedef enum {
+	ZPOOL_PROP_INVAL = -1,
 	ZPOOL_PROP_NAME,
 	ZPOOL_PROP_SIZE,
 	ZPOOL_PROP_CAPACITY,
@@ -213,9 +216,6 @@ typedef enum {
 
 /* Small enough to not hog a whole line of printout in zpool(1M). */
 #define	ZPROP_MAX_COMMENT	32
-
-#define	ZPROP_CONT		-2
-#define	ZPROP_INVAL		-1
 
 #define	ZPROP_VALUE		"value"
 #define	ZPROP_SOURCE		"source"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801220552.w0M5qdxP062338>