From 648a09adc25cc1b8b9bec72130ab219a3e544b56 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 17 Jan 2017 14:45:02 -0800 Subject: [PATCH] OpenZFS 6550 - cmd/zfs: cleanup gcc warnings Porting Notes: - Many of the fixes proposed by this patch were already applied. In the cases where a different but equivalent fix was made the code was updated with the OpenZFS version to minimize differences. Authored by: Igor Kozhukhov Reviewed by: Matthew Ahrens Reviewed by: Andy Stormont Approved by: Dan McDonald Reviewed-by: George Melikov Ported-by: Brian Behlendorf OpenZFS-issue: https://www.illumos.org/issues/6550 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c16bcc4 Closes #5591 --- cmd/zfs/zfs_main.c | 38 +++++++++++++++++++++++--------------- include/sys/fs/zfs.h | 3 ++- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index c31f1b5d2..3b72d60f2 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -26,6 +26,7 @@ * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Igor Kozhukhov . */ #include @@ -857,7 +858,7 @@ zfs_do_create(int argc, char **argv) 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) @@ -2353,6 +2354,7 @@ compare_nums: if (rv64 != lv64) rc = (rv64 < lv64) ? 1 : -1; break; + default: break; } @@ -3980,7 +3982,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; @@ -4263,7 +4265,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; @@ -4483,7 +4485,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) { @@ -4580,8 +4582,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: - break; + assert(!"unhandled zfs_deleg_who_type_t"); } if (is_set) { @@ -4617,6 +4620,7 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl) if (g) nice_name = g->gr_name; break; + default: break; } @@ -4954,8 +4958,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[MAXNAMELEN + 32]; - char base_type = ZFS_DELEG_WHO_UNKNOWN; - char set_type = ZFS_DELEG_WHO_UNKNOWN; + char base_type = '\0'; + char set_type = '\0'; nvlist_t *base_nvl = NULL; nvlist_t *set_nvl = NULL; nvlist_t *nvl; @@ -5004,8 +5008,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; - default: break; + + default: + assert(set_type != '\0' && base_type != '\0'); } if (perms != NULL) { @@ -5239,7 +5245,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) { @@ -5290,8 +5296,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; - default: break; + + default: + assert(who != NULL); } prt_who = B_FALSE; @@ -5996,10 +6004,10 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, shared_smb = zfs_is_shared_smb(zhp, NULL); if ((shared_nfs && shared_smb) || - ((shared_nfs && strcmp(shareopts, "on") == 0) && - (strcmp(smbshareopts, "off") == 0)) || - ((shared_smb && strcmp(smbshareopts, "on") == 0) && - (strcmp(shareopts, "off") == 0))) { + (shared_nfs && strcmp(shareopts, "on") == 0 && + strcmp(smbshareopts, "off") == 0) || + (shared_smb && strcmp(smbshareopts, "on") == 0 && + strcmp(shareopts, "off") == 0)) { if (!explicit) return (0); @@ -6787,7 +6795,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/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index 45b6d4981..f09e4bfa0 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -82,7 +82,8 @@ typedef enum dmu_objset_type { * the property table in module/zcommon/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,