Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet fix a few warnings.



details:   https://anonhg.NetBSD.org/src/rev/91c7628fda71
branches:  trunk
changeset: 350353:91c7628fda71
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 10 19:20:34 2017 +0000

description:
fix a few warnings.

diffstat:

 external/cddl/osnet/dist/lib/libzfs/common/libzfs.h      |    2 +-
 external/cddl/osnet/dist/lib/libzfs/common/libzfs_pool.c |  115 +++++++++-----
 external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h     |    4 +-
 external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h     |    2 +-
 external/cddl/osnet/include/devid.h                      |    6 +-
 external/cddl/osnet/lib/libzfs/deviceid.c                |    8 +-
 external/cddl/osnet/sys/sys/zfs_context.h                |    4 +-
 7 files changed, 83 insertions(+), 58 deletions(-)

diffs (truncated from 428 to 300 lines):

diff -r 052fc10f07cd -r 91c7628fda71 external/cddl/osnet/dist/lib/libzfs/common/libzfs.h
--- a/external/cddl/osnet/dist/lib/libzfs/common/libzfs.h       Tue Jan 10 17:51:01 2017 +0000
+++ b/external/cddl/osnet/dist/lib/libzfs/common/libzfs.h       Tue Jan 10 19:20:34 2017 +0000
@@ -198,7 +198,7 @@
 extern void zpool_close(zpool_handle_t *);
 extern const char *zpool_get_name(zpool_handle_t *);
 extern int zpool_get_state(zpool_handle_t *);
-extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
+extern const char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
 extern void zpool_free_handles(libzfs_handle_t *);
 
 /*
diff -r 052fc10f07cd -r 91c7628fda71 external/cddl/osnet/dist/lib/libzfs/common/libzfs_pool.c
--- a/external/cddl/osnet/dist/lib/libzfs/common/libzfs_pool.c  Tue Jan 10 17:51:01 2017 +0000
+++ b/external/cddl/osnet/dist/lib/libzfs/common/libzfs_pool.c  Tue Jan 10 19:20:34 2017 +0000
@@ -36,6 +36,7 @@
 #include <sys/efi_partition.h>
 #include <sys/vtoc.h>
 #include <sys/zfs_ioctl.h>
+#include <sys/stat.h>
 #include <dlfcn.h>
 
 #include "zfs_namecheck.h"
@@ -168,14 +169,14 @@
                verify(nvlist_lookup_string(nv, ZPROP_VALUE, &value) == 0);
        } else {
                source = ZPROP_SRC_DEFAULT;
-               if ((value = (char *)zpool_prop_default_string(prop)) == NULL)
-                       value = "-";
+               if ((value = __UNCONST(zpool_prop_default_string(prop))) == NULL)
+                       value = __UNCONST("-");
        }
 
        if (src)
                *src = source;
 
-       return (value);
+       return value;
 }
 
 uint64_t
@@ -220,7 +221,7 @@
 /*
  * Map VDEV STATE to printed strings.
  */
-char *
+const char *
 zpool_state_to_name(vdev_state_t state, vdev_aux_t aux)
 {
        switch (state) {
@@ -242,9 +243,10 @@
                return (gettext("DEGRADED"));
        case VDEV_STATE_HEALTHY:
                return (gettext("ONLINE"));
+       case VDEV_STATE_UNKNOWN:
+       default:
+               return (gettext("UNKNOWN"));
        }
-
-       return (gettext("UNKNOWN"));
 }
 
 /*
@@ -274,7 +276,7 @@
 
                case ZPOOL_PROP_GUID:
                        intval = zpool_get_prop_int(zhp, prop, &src);
-                       (void) snprintf(buf, len, "%llu", intval);
+                       (void) snprintf(buf, len, "%" PRIu64, intval);
                        break;
 
                case ZPOOL_PROP_ALTROOT:
@@ -320,14 +322,14 @@
                        break;
 
                case ZPOOL_PROP_CAPACITY:
-                       (void) snprintf(buf, len, "%llu%%",
-                           (u_longlong_t)intval);
+                       (void) snprintf(buf, len, "%ju%%",
+                           (uintmax_t)intval);
                        break;
 
                case ZPOOL_PROP_DEDUPRATIO:
-                       (void) snprintf(buf, len, "%llu.%02llux",
-                           (u_longlong_t)(intval / 100),
-                           (u_longlong_t)(intval % 100));
+                       (void) snprintf(buf, len, "%ju.%02jux",
+                           (uintmax_t)(intval / 100),
+                           (uintmax_t)(intval % 100));
                        break;
 
                case ZPOOL_PROP_HEALTH:
@@ -340,7 +342,7 @@
                            vs->vs_aux), len);
                        break;
                default:
-                       (void) snprintf(buf, len, "%llu", intval);
+                       (void) snprintf(buf, len, "%ju", (uintmax_t)intval);
                }
                break;
 
@@ -585,6 +587,22 @@
 
                        *slash = '/';
                        break;
+               case ZPOOL_PROP_FREE:
+               case ZPOOL_PROP_ALLOCATED:
+               case ZPOOL_NUM_PROPS:
+               case ZPOOL_PROP_AUTOEXPAND:
+               case ZPOOL_PROP_DEDUPDITTO:
+               case ZPOOL_PROP_SIZE:
+               case ZPOOL_PROP_CAPACITY:
+               case ZPOOL_PROP_HEALTH:
+               case ZPOOL_PROP_GUID:
+               case ZPOOL_PROP_DELEGATION:
+               case ZPOOL_PROP_AUTOREPLACE:
+               case ZPOOL_PROP_FAILUREMODE:
+               case ZPOOL_PROP_LISTSNAPS:
+               case ZPOOL_PROP_DEDUPRATIO:
+               case ZPOOL_PROP_NAME:
+                       break;
                }
        }
 
@@ -764,7 +782,10 @@
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                                    "multiple '@' delimiters in name"));
                                break;
-
+                       case NAME_ERR_NO_AT:
+                               zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                                   "no attribute in name"));
+                               break;
                        }
                }
                return (B_FALSE);
@@ -1206,7 +1227,7 @@
  * Exports the pool from the system.  The caller must ensure that there are no
  * mounted datasets in the pool.
  */
-int
+static int
 zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce)
 {
        zfs_cmd_t zc = { 0 };
@@ -1267,7 +1288,7 @@
        (void) nvlist_lookup_int64(rbi, ZPOOL_CONFIG_REWIND_TIME, &loss);
 
        if (localtime_r((time_t *)&rewindto, &t) != NULL &&
-           strftime(timestr, 128, 0, &t) != 0) {
+           strftime(timestr, 128, "", &t) != 0) {
                if (dryrun) {
                        (void) printf(dgettext(TEXT_DOMAIN,
                            "Would be able to return %s "
@@ -1280,15 +1301,16 @@
                }
                if (loss > 120) {
                        (void) printf(dgettext(TEXT_DOMAIN,
-                           "%s approximately %lld "),
+                           "%s approximately %jd "),
                            dryrun ? "Would discard" : "Discarded",
-                           (loss + 30) / 60);
+                           ((uintmax_t)(loss + 30) / 60));
                        (void) printf(dgettext(TEXT_DOMAIN,
                            "minutes of transactions.\n"));
                } else if (loss > 0) {
                        (void) printf(dgettext(TEXT_DOMAIN,
-                           "%s approximately %lld "),
-                           dryrun ? "Would discard" : "Discarded", loss);
+                           "%s approximately %jd "),
+                           dryrun ? "Would discard" : "Discarded",
+                           (uintmax_t)loss);
                        (void) printf(dgettext(TEXT_DOMAIN,
                            "seconds of transactions.\n"));
                }
@@ -1326,7 +1348,7 @@
            "Recovery is possible, but will result in some data loss.\n"));
 
        if (localtime_r((time_t *)&rewindto, &t) != NULL &&
-           strftime(timestr, 128, 0, &t) != 0) {
+           strftime(timestr, 128, "", &t) != 0) {
                (void) printf(dgettext(TEXT_DOMAIN,
                    "\tReturning the pool to its state as of %s\n"
                    "\tshould correct the problem.  "),
@@ -1339,12 +1361,13 @@
 
        if (loss > 120) {
                (void) printf(dgettext(TEXT_DOMAIN,
-                   "Approximately %lld minutes of data\n"
-                   "\tmust be discarded, irreversibly.  "), (loss + 30) / 60);
+                   "Approximately %jd minutes of data\n"
+                   "\tmust be discarded, irreversibly.  "),
+                   (uintmax_t)((loss + 30) / 60));
        } else if (loss > 0) {
                (void) printf(dgettext(TEXT_DOMAIN,
-                   "Approximately %lld seconds of data\n"
-                   "\tmust be discarded, irreversibly.  "), loss);
+                   "Approximately %jd seconds of data\n"
+                   "\tmust be discarded, irreversibly.  "), (uintmax_t)loss);
        }
        if (edata != 0 && edata != UINT64_MAX) {
                if (edata == 1) {
@@ -1439,7 +1462,7 @@
                        return (zfs_error_fmt(hdl, EZFS_INVALIDNAME,
                            dgettext(TEXT_DOMAIN, "cannot import '%s'"),
                            newname));
-               thename = (char *)newname;
+               thename = __UNCONST(newname);
        } else {
                thename = origname;
        }
@@ -1784,7 +1807,7 @@
 /*
  * Determine if we have an "interior" top-level vdev (i.e mirror/raidz).
  */
-boolean_t
+static boolean_t
 zpool_vdev_is_interior(const char *name)
 {
        if (strncmp(name, VDEV_TYPE_RAIDZ, strlen(VDEV_TYPE_RAIDZ)) == 0 ||
@@ -1908,17 +1931,17 @@
            (is_spare = (strcmp(type, VDEV_TYPE_SPARE) == 0))) {
                nvlist_t **child;
                uint_t count;
-               int i, ret;
+               int i, rv;
 
                if (nvlist_lookup_nvlist_array(nv,
                    ZPOOL_CONFIG_CHILDREN, &child, &count) != 0)
                        return (EZFS_INVALCONFIG);
 
                for (i = 0; i < count; i++) {
-                       ret = vdev_get_physpaths(child[i], physpath,
+                       rv = vdev_get_physpaths(child[i], physpath,
                            phypath_size, rsz, is_spare);
-                       if (ret == EZFS_NOSPC)
-                               return (ret);
+                       if (rv == EZFS_NOSPC)
+                               return (rv);
                }
        }
 
@@ -2152,7 +2175,7 @@
        libzfs_handle_t *hdl = zhp->zpool_hdl;
 
        (void) snprintf(msg, sizeof (msg),
-           dgettext(TEXT_DOMAIN, "cannot fault %llu"), guid);
+           dgettext(TEXT_DOMAIN, "cannot fault %ju"), (uintmax_t)guid);
 
        (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
        zc.zc_guid = guid;
@@ -2187,7 +2210,7 @@
        libzfs_handle_t *hdl = zhp->zpool_hdl;
 
        (void) snprintf(msg, sizeof (msg),
-           dgettext(TEXT_DOMAIN, "cannot degrade %llu"), guid);
+           dgettext(TEXT_DOMAIN, "cannot degrade %ju"), (uintmax_t)guid);
 
        (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
        zc.zc_guid = guid;
@@ -2853,8 +2876,8 @@
        libzfs_handle_t *hdl = zhp->zpool_hdl;
 
        (void) snprintf(msg, sizeof (msg),
-           dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
-           guid);
+           dgettext(TEXT_DOMAIN, "cannot clear errors for %x"),
+           (uintmax_t)guid);
 
        (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
        zc.zc_guid = guid;
@@ -2970,8 +2993,8 @@
            &value) == 0) {
                verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID,
                    &value) == 0);
-               (void) snprintf(buf, sizeof (buf), "%llu",
-                   (u_longlong_t)value);
+               (void) snprintf(buf, sizeof (buf), "%ju",
+                   (uintmax_t)value);
                path = buf;
        } else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) {
 
@@ -3033,8 +3056,8 @@
                if (strcmp(path, VDEV_TYPE_RAIDZ) == 0) {
                        verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY,
                            &value) == 0);
-                       (void) snprintf(buf, sizeof (buf), "%s%llu", path,
-                           (u_longlong_t)value);
+                       (void) snprintf(buf, sizeof (buf), "%s%ju", path,
+                           (uintmax_t)value);
                        path = buf;
                }
 
@@ -3047,8 +3070,8 @@
 
                        verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID,
                            &id) == 0);
-                       (void) snprintf(buf, sizeof (buf), "%s-%llu", path,
-                           (u_longlong_t)id);
+                       (void) snprintf(buf, sizeof (buf), "%s-%ju", path,



Home | Main Index | Thread Index | Old Index