Rebase master to b108
[zfs.git] / lib / libzfs / libzfs_util.c
index 54de0f4..259f5fd 100644 (file)
@@ -480,7 +480,6 @@ zfs_realloc(libzfs_handle_t *hdl, void *ptr, size_t oldsize, size_t newsize)
 
        if ((ret = realloc(ptr, newsize)) == NULL) {
                (void) no_memory(hdl);
-               free(ptr);
                return (NULL);
        }
 
@@ -796,6 +795,10 @@ zprop_print_headers(zprop_get_cbdata_t *cbp, zfs_type_t type)
        cbp->cb_colwidths[GET_COL_SOURCE] = strlen(dgettext(TEXT_DOMAIN,
            "SOURCE"));
 
+       /* first property is always NAME */
+       assert(cbp->cb_proplist->pl_prop ==
+           ((type == ZFS_TYPE_POOL) ?  ZPOOL_PROP_NAME : ZFS_PROP_NAME));
+
        /*
         * Go through and calculate the widths for each column.  For the
         * 'source' column, we kludge it up by taking the worst-case scenario of
@@ -823,9 +826,13 @@ zprop_print_headers(zprop_get_cbdata_t *cbp, zfs_type_t type)
                }
 
                /*
-                * 'VALUE' column
+                * 'VALUE' column.  The first property is always the 'name'
+                * property that was tacked on either by /sbin/zfs's
+                * zfs_do_get() or when calling zprop_expand_list(), so we
+                * ignore its width.  If the user specified the name property
+                * to display, then it will be later in the list in any case.
                 */
-               if ((pl->pl_prop != ZFS_PROP_NAME || !pl->pl_all) &&
+               if (pl != cbp->cb_proplist &&
                    pl->pl_width > cbp->cb_colwidths[GET_COL_VALUE])
                        cbp->cb_colwidths[GET_COL_VALUE] = pl->pl_width;
 
@@ -1010,9 +1017,9 @@ zfs_nicestrtonum(libzfs_handle_t *hdl, const char *value, uint64_t *num)
                return (-1);
        }
 
-       /* Rely on stroll() to process the numeric portion.  */
+       /* Rely on stroull() to process the numeric portion.  */
        errno = 0;
-       *num = strtoll(value, &end, 10);
+       *num = strtoull(value, &end, 10);
 
        /*
         * Check for ERANGE, which indicates that the value is too large to fit