diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/zfs/Makefile | 7 | ||||
-rw-r--r-- | usr/src/cmd/zfs/zfs_main.c | 54 | ||||
-rw-r--r-- | usr/src/cmd/zpool/Makefile | 5 | ||||
-rw-r--r-- | usr/src/cmd/zpool/zpool_iter.c | 8 | ||||
-rw-r--r-- | usr/src/cmd/zpool/zpool_main.c | 32 | ||||
-rw-r--r-- | usr/src/cmd/zpool/zpool_vdev.c | 7 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fs/zfs.h | 3 |
7 files changed, 54 insertions, 62 deletions
diff --git a/usr/src/cmd/zfs/Makefile b/usr/src/cmd/zfs/Makefile index 3007b82213..4e420460d3 100644 --- a/usr/src/cmd/zfs/Makefile +++ b/usr/src/cmd/zfs/Makefile @@ -23,6 +23,7 @@ # # Copyright 2010 Nexenta Systems, Inc. All rights reserved. # Copyright (c) 2012 by Delphix. All rights reserved. +# Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. # PROG= zfs @@ -53,12 +54,6 @@ $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2 LINTFLAGS64 += -xerroff=E_NAME_DEF_NOT_USED2 -CERRWARN += -_gcc=-Wno-switch -CERRWARN += -_gcc=-Wno-type-limits -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-uninitialized -CERRWARN += -_gcc=-Wno-old-style-declaration - ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%) USRLIBFSTYPELINKS = $(LINKPROGS:%=$(USRLIBFSTYPE)/%) ROOTETCFSTYPELINKS = $(LINKPROGS:%=$(ROOTETCFSTYPE)/%) diff --git a/usr/src/cmd/zfs/zfs_main.c b/usr/src/cmd/zfs/zfs_main.c index 8ebe2b5f94..8f38a11ba5 100644 --- a/usr/src/cmd/zfs/zfs_main.c +++ b/usr/src/cmd/zfs/zfs_main.c @@ -27,6 +27,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. */ #include <assert.h> @@ -745,7 +746,7 @@ zfs_do_create(int argc, char **argv) { zfs_type_t type = ZFS_TYPE_FILESYSTEM; zfs_handle_t *zhp = NULL; - uint64_t volsize; + uint64_t volsize = 0; int c; boolean_t noreserve = B_FALSE; boolean_t bflag = B_FALSE; @@ -831,14 +832,14 @@ zfs_do_create(int argc, char **argv) if (type == ZFS_TYPE_VOLUME && !noreserve) { zpool_handle_t *zpool_handle; - nvlist_t *real_props; + nvlist_t *real_props = NULL; uint64_t spa_version; char *p; zfs_prop_t resv_prop; char *strval; char msg[1024]; - if (p = strchr(argv[0], '/')) + if ((p = strchr(argv[0], '/')) != NULL) *p = '\0'; zpool_handle = zpool_open(g_zfs, argv[0]); if (p != NULL) @@ -2398,6 +2399,9 @@ us_compare(const void *larg, const void *rarg, void *unused) if (rv64 != lv64) rc = (rv64 < lv64) ? 1 : -1; break; + + default: + break; } if (rc != 0) { @@ -2453,7 +2457,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space) nvlist_t *props; us_node_t *n; zfs_sort_column_t *sortcol = cb->cb_sortcol; - unsigned type; + unsigned type = 0; const char *typestr; size_t namelen; size_t typelen; @@ -3973,7 +3977,7 @@ zfs_do_send(int argc, char **argv) static int zfs_do_receive(int argc, char **argv) { - int c, err; + int c, err = 0; recvflags_t flags = { 0 }; boolean_t abort_resumable = B_FALSE; @@ -4233,7 +4237,7 @@ deleg_perm_type(zfs_deleg_note_t note) } } -static int inline +static int who_type2weight(zfs_deleg_who_type_t who_type) { int res; @@ -4453,7 +4457,7 @@ fs_perm_fini(fs_perm_t *fsperm) uu_avl_destroy(fsperm->fsp_uge_avl); } -static void inline +static void set_deleg_perm_node(uu_avl_t *avl, deleg_perm_node_t *node, zfs_deleg_who_type_t who_type, const char *name, char locality) { @@ -4521,7 +4525,7 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl) nvlist_t *nvl2 = NULL; const char *name = nvpair_name(nvp); uu_avl_t *avl = NULL; - uu_avl_pool_t *avl_pool; + uu_avl_pool_t *avl_pool = NULL; zfs_deleg_who_type_t perm_type = name[0]; char perm_locality = name[1]; const char *perm_name = name + 3; @@ -4550,6 +4554,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl) avl_pool = fspset->fsps_who_perm_avl_pool; avl = fsperm->fsp_uge_avl; break; + + default: + assert(!"unhandled zfs_deleg_who_type_t"); } if (is_set) { @@ -4585,6 +4592,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl) if (g) nice_name = g->gr_name; break; + + default: + break; } if (nice_name != NULL) @@ -4853,11 +4863,12 @@ parse_allow_args(int argc, char **argv, boolean_t un, struct allow_opts *opts) allow_usage(un, B_FALSE, gettext("-u, -g, and -e are mutually exclusive\n")); - if (opts->prt_usage) + if (opts->prt_usage) { if (argc == 0 && all_sum == 0) allow_usage(un, B_TRUE, NULL); else usage(B_FALSE); + } if (opts->set) { if (csuge_sum > 1) @@ -4906,8 +4917,8 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend, int i; char ld[2] = { '\0', '\0' }; char who_buf[ZFS_MAXNAMELEN+32]; - char base_type; - char set_type; + char base_type = '\0'; + char set_type = '\0'; nvlist_t *base_nvl = NULL; nvlist_t *set_nvl = NULL; nvlist_t *nvl; @@ -4956,6 +4967,10 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend, ld[0] = ZFS_DELEG_LOCAL; if (descend) ld[1] = ZFS_DELEG_DESCENDENT; + break; + + default: + assert(set_type != '\0' && base_type != '\0'); } if (perms != NULL) { @@ -5060,7 +5075,7 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp) while (curr < end) { const char *who; - zfs_deleg_who_type_t who_type; + zfs_deleg_who_type_t who_type = ZFS_DELEG_WHO_UNKNOWN; char *endch; char *delim = strchr(curr, ','); char errbuf[256]; @@ -5110,12 +5125,13 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp) p = getpwuid(rid); } - if (p == NULL) + if (p == NULL) { if (*endch != '\0') { g = getgrnam(curr); } else { g = getgrgid(rid); } + } if (p != NULL) { who_type = ZFS_DELEG_USER; @@ -5188,7 +5204,7 @@ print_set_creat_perms(uu_avl_t *who_avl) } } -static void inline +static void print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend, const char *title) { @@ -5239,6 +5255,10 @@ print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend, case ZFS_DELEG_EVERYONE: who = gettext("everyone"); who_name = NULL; + break; + + default: + assert(who != NULL); } prt_who = B_FALSE; @@ -5943,7 +5963,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, shared_nfs = zfs_is_shared_nfs(zhp, NULL); shared_smb = zfs_is_shared_smb(zhp, NULL); - if (shared_nfs && shared_smb || + if ((shared_nfs && shared_smb) || (shared_nfs && strcmp(shareopts, "on") == 0 && strcmp(smbshareopts, "off") == 0) || (shared_smb && strcmp(smbshareopts, "on") == 0 && @@ -6402,7 +6422,7 @@ unshare_unmount(int op, int argc, char **argv) */ struct mnttab entry; uu_avl_pool_t *pool; - uu_avl_t *tree; + uu_avl_t *tree = NULL; unshare_unmount_node_t *node; uu_avl_index_t idx; uu_avl_walk_t *walk; @@ -6832,7 +6852,7 @@ zfs_do_diff(int argc, char **argv) if (copy == NULL) usage(B_FALSE); - if (atp = strchr(copy, '@')) + if ((atp = strchr(copy, '@')) != NULL) *atp = '\0'; if ((zhp = zfs_open(g_zfs, copy, ZFS_TYPE_FILESYSTEM)) == NULL) diff --git a/usr/src/cmd/zpool/Makefile b/usr/src/cmd/zpool/Makefile index 0c0132d075..8fd0a0f76e 100644 --- a/usr/src/cmd/zpool/Makefile +++ b/usr/src/cmd/zpool/Makefile @@ -20,6 +20,7 @@ # # # Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. # PROG= zpool @@ -48,10 +49,6 @@ $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2 LINTFLAGS64 += -xerroff=E_NAME_DEF_NOT_USED2 -CERRWARN += -_gcc=-Wno-unused-function -CERRWARN += -_gcc=-Wno-uninitialized -CERRWARN += -_gcc=-Wno-parentheses - ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%) .KEEP_STATE: diff --git a/usr/src/cmd/zpool/zpool_iter.c b/usr/src/cmd/zpool/zpool_iter.c index 2f0daefd55..6e77f85fa3 100644 --- a/usr/src/cmd/zpool/zpool_iter.c +++ b/usr/src/cmd/zpool/zpool_iter.c @@ -22,8 +22,9 @@ * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. + */ #include <libintl.h> #include <libuutil.h> @@ -131,7 +132,8 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err) for (i = 0; i < argc; i++) { zpool_handle_t *zhp; - if (zhp = zpool_open_canfail(g_zfs, argv[i])) { + if ((zhp = zpool_open_canfail(g_zfs, argv[i])) != + NULL) { if (add_pool(zhp, zlp) != 0) *err = B_TRUE; } else { diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c index 48138c1c1b..b22d5e2e9c 100644 --- a/usr/src/cmd/zpool/zpool_main.c +++ b/usr/src/cmd/zpool/zpool_main.c @@ -26,6 +26,7 @@ * Copyright (c) 2012 by Frederik Wessels. All rights reserved. * Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved. * Copyright (c) 2013 Joyent, Inc. All rights reserved. + * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. */ #include <assert.h> @@ -3026,33 +3027,6 @@ zpool_do_list(int argc, char **argv) return (ret); } -static nvlist_t * -zpool_get_vdev_by_name(nvlist_t *nv, char *name) -{ - nvlist_t **child; - uint_t c, children; - nvlist_t *match; - char *path; - - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, - &child, &children) != 0) { - verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0); - if (strncmp(name, "/dev/dsk/", 9) == 0) - name += 9; - if (strncmp(path, "/dev/dsk/", 9) == 0) - path += 9; - if (strcmp(name, path) == 0) - return (nv); - return (NULL); - } - - for (c = 0; c < children; c++) - if ((match = zpool_get_vdev_by_name(child[c], name)) != NULL) - return (match); - - return (NULL); -} - static int zpool_do_attach_or_replace(int argc, char **argv, int replacing) { @@ -3783,7 +3757,7 @@ print_scan_status(pool_scan_stat_t *ps) */ if (ps->pss_state == DSS_FINISHED) { uint64_t minutes_taken = (end - start) / 60; - char *fmt; + char *fmt = NULL; if (ps->pss_func == POOL_SCAN_SCRUB) { fmt = gettext("scrub repaired %s in %lluh%um with " @@ -5269,7 +5243,7 @@ find_command_idx(char *command, int *idx) int main(int argc, char **argv) { - int ret; + int ret = 0; int i; char *cmdname; diff --git a/usr/src/cmd/zpool/zpool_vdev.c b/usr/src/cmd/zpool/zpool_vdev.c index 95a6bd7c17..7b65e80723 100644 --- a/usr/src/cmd/zpool/zpool_vdev.c +++ b/usr/src/cmd/zpool/zpool_vdev.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. */ /* @@ -549,7 +550,9 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) uint_t c, children; nvlist_t *nv; char *type; - replication_level_t lastrep, rep, *ret; + replication_level_t lastrep = {0}; + replication_level_t rep; + replication_level_t *ret; boolean_t dontreport; ret = safe_malloc(sizeof (replication_level_t)); @@ -1035,7 +1038,7 @@ is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, nvlist_t **child; uint_t c, children; char *type, *path; - int ret; + int ret = 0; char buf[MAXPATHLEN]; uint64_t wholedisk; boolean_t anyinuse = B_FALSE; diff --git a/usr/src/uts/common/sys/fs/zfs.h b/usr/src/uts/common/sys/fs/zfs.h index 6301f25087..f6f913c119 100644 --- a/usr/src/uts/common/sys/fs/zfs.h +++ b/usr/src/uts/common/sys/fs/zfs.h @@ -78,7 +78,8 @@ typedef enum dmu_objset_type { * the property table in usr/src/common/zfs/zfs_prop.c. */ typedef enum { - ZFS_PROP_TYPE, + ZFS_PROP_BAD = -1, + ZFS_PROP_TYPE = 0, ZFS_PROP_CREATION, ZFS_PROP_USED, ZFS_PROP_AVAILABLE, |