|
27 | 27 | * Copyright (c) 2013 Steven Hartland. All rights reserved.
|
28 | 28 | * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
|
29 | 29 | * Copyright (c) 2014 Integros [integros.com]
|
| 30 | + * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. |
30 | 31 | */
|
31 | 32 |
|
32 | 33 | #include <assert.h>
|
@@ -731,7 +732,7 @@ zfs_do_create(int argc, char **argv)
|
731 | 732 | {
|
732 | 733 | zfs_type_t type = ZFS_TYPE_FILESYSTEM;
|
733 | 734 | zfs_handle_t *zhp = NULL;
|
734 |
| - uint64_t volsize; |
| 735 | + uint64_t volsize = 0; |
735 | 736 | int c;
|
736 | 737 | boolean_t noreserve = B_FALSE;
|
737 | 738 | boolean_t bflag = B_FALSE;
|
@@ -817,14 +818,14 @@ zfs_do_create(int argc, char **argv)
|
817 | 818 |
|
818 | 819 | if (type == ZFS_TYPE_VOLUME && !noreserve) {
|
819 | 820 | zpool_handle_t *zpool_handle;
|
820 |
| - nvlist_t *real_props; |
| 821 | + nvlist_t *real_props = NULL; |
821 | 822 | uint64_t spa_version;
|
822 | 823 | char *p;
|
823 | 824 | zfs_prop_t resv_prop;
|
824 | 825 | char *strval;
|
825 | 826 | char msg[1024];
|
826 | 827 |
|
827 |
| - if (p = strchr(argv[0], '/')) |
| 828 | + if ((p = strchr(argv[0], '/')) != NULL) |
828 | 829 | *p = '\0';
|
829 | 830 | zpool_handle = zpool_open(g_zfs, argv[0]);
|
830 | 831 | if (p != NULL)
|
@@ -2331,6 +2332,9 @@ us_compare(const void *larg, const void *rarg, void *unused)
|
2331 | 2332 | if (rv64 != lv64)
|
2332 | 2333 | rc = (rv64 < lv64) ? 1 : -1;
|
2333 | 2334 | break;
|
| 2335 | + |
| 2336 | + default: |
| 2337 | + break; |
2334 | 2338 | }
|
2335 | 2339 |
|
2336 | 2340 | if (rc != 0) {
|
@@ -2386,7 +2390,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
|
2386 | 2390 | nvlist_t *props;
|
2387 | 2391 | us_node_t *n;
|
2388 | 2392 | zfs_sort_column_t *sortcol = cb->cb_sortcol;
|
2389 |
| - unsigned type; |
| 2393 | + unsigned type = 0; |
2390 | 2394 | const char *typestr;
|
2391 | 2395 | size_t namelen;
|
2392 | 2396 | size_t typelen;
|
@@ -3893,7 +3897,7 @@ zfs_do_send(int argc, char **argv)
|
3893 | 3897 | static int
|
3894 | 3898 | zfs_do_receive(int argc, char **argv)
|
3895 | 3899 | {
|
3896 |
| - int c, err; |
| 3900 | + int c, err = 0; |
3897 | 3901 | recvflags_t flags = { 0 };
|
3898 | 3902 | boolean_t abort_resumable = B_FALSE;
|
3899 | 3903 |
|
@@ -4153,7 +4157,7 @@ deleg_perm_type(zfs_deleg_note_t note)
|
4153 | 4157 | }
|
4154 | 4158 | }
|
4155 | 4159 |
|
4156 |
| -static int inline |
| 4160 | +static int |
4157 | 4161 | who_type2weight(zfs_deleg_who_type_t who_type)
|
4158 | 4162 | {
|
4159 | 4163 | int res;
|
@@ -4373,7 +4377,7 @@ fs_perm_fini(fs_perm_t *fsperm)
|
4373 | 4377 | uu_avl_destroy(fsperm->fsp_uge_avl);
|
4374 | 4378 | }
|
4375 | 4379 |
|
4376 |
| -static void inline |
| 4380 | +static void |
4377 | 4381 | set_deleg_perm_node(uu_avl_t *avl, deleg_perm_node_t *node,
|
4378 | 4382 | zfs_deleg_who_type_t who_type, const char *name, char locality)
|
4379 | 4383 | {
|
@@ -4441,7 +4445,7 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
|
4441 | 4445 | nvlist_t *nvl2 = NULL;
|
4442 | 4446 | const char *name = nvpair_name(nvp);
|
4443 | 4447 | uu_avl_t *avl = NULL;
|
4444 |
| - uu_avl_pool_t *avl_pool; |
| 4448 | + uu_avl_pool_t *avl_pool = NULL; |
4445 | 4449 | zfs_deleg_who_type_t perm_type = name[0];
|
4446 | 4450 | char perm_locality = name[1];
|
4447 | 4451 | const char *perm_name = name + 3;
|
@@ -4470,6 +4474,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
|
4470 | 4474 | avl_pool = fspset->fsps_who_perm_avl_pool;
|
4471 | 4475 | avl = fsperm->fsp_uge_avl;
|
4472 | 4476 | break;
|
| 4477 | + |
| 4478 | + default: |
| 4479 | + assert(!"unhandled zfs_deleg_who_type_t"); |
4473 | 4480 | }
|
4474 | 4481 |
|
4475 | 4482 | if (is_set) {
|
@@ -4505,6 +4512,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
|
4505 | 4512 | if (g)
|
4506 | 4513 | nice_name = g->gr_name;
|
4507 | 4514 | break;
|
| 4515 | + |
| 4516 | + default: |
| 4517 | + break; |
4508 | 4518 | }
|
4509 | 4519 |
|
4510 | 4520 | if (nice_name != NULL)
|
@@ -4773,11 +4783,12 @@ parse_allow_args(int argc, char **argv, boolean_t un, struct allow_opts *opts)
|
4773 | 4783 | allow_usage(un, B_FALSE,
|
4774 | 4784 | gettext("-u, -g, and -e are mutually exclusive\n"));
|
4775 | 4785 |
|
4776 |
| - if (opts->prt_usage) |
| 4786 | + if (opts->prt_usage) { |
4777 | 4787 | if (argc == 0 && all_sum == 0)
|
4778 | 4788 | allow_usage(un, B_TRUE, NULL);
|
4779 | 4789 | else
|
4780 | 4790 | usage(B_FALSE);
|
| 4791 | + } |
4781 | 4792 |
|
4782 | 4793 | if (opts->set) {
|
4783 | 4794 | if (csuge_sum > 1)
|
@@ -4826,8 +4837,8 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
|
4826 | 4837 | int i;
|
4827 | 4838 | char ld[2] = { '\0', '\0' };
|
4828 | 4839 | char who_buf[ZFS_MAXNAMELEN+32];
|
4829 |
| - char base_type; |
4830 |
| - char set_type; |
| 4840 | + char base_type = '\0'; |
| 4841 | + char set_type = '\0'; |
4831 | 4842 | nvlist_t *base_nvl = NULL;
|
4832 | 4843 | nvlist_t *set_nvl = NULL;
|
4833 | 4844 | nvlist_t *nvl;
|
@@ -4876,6 +4887,10 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
|
4876 | 4887 | ld[0] = ZFS_DELEG_LOCAL;
|
4877 | 4888 | if (descend)
|
4878 | 4889 | ld[1] = ZFS_DELEG_DESCENDENT;
|
| 4890 | + break; |
| 4891 | + |
| 4892 | + default: |
| 4893 | + assert(set_type != '\0' && base_type != '\0'); |
4879 | 4894 | }
|
4880 | 4895 |
|
4881 | 4896 | if (perms != NULL) {
|
@@ -4980,7 +4995,7 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp)
|
4980 | 4995 |
|
4981 | 4996 | while (curr < end) {
|
4982 | 4997 | const char *who;
|
4983 |
| - zfs_deleg_who_type_t who_type; |
| 4998 | + zfs_deleg_who_type_t who_type = ZFS_DELEG_WHO_UNKNOWN; |
4984 | 4999 | char *endch;
|
4985 | 5000 | char *delim = strchr(curr, ',');
|
4986 | 5001 | char errbuf[256];
|
@@ -5030,12 +5045,13 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp)
|
5030 | 5045 | p = getpwuid(rid);
|
5031 | 5046 | }
|
5032 | 5047 |
|
5033 |
| - if (p == NULL) |
| 5048 | + if (p == NULL) { |
5034 | 5049 | if (*endch != '\0') {
|
5035 | 5050 | g = getgrnam(curr);
|
5036 | 5051 | } else {
|
5037 | 5052 | g = getgrgid(rid);
|
5038 | 5053 | }
|
| 5054 | + } |
5039 | 5055 |
|
5040 | 5056 | if (p != NULL) {
|
5041 | 5057 | who_type = ZFS_DELEG_USER;
|
@@ -5108,7 +5124,7 @@ print_set_creat_perms(uu_avl_t *who_avl)
|
5108 | 5124 | }
|
5109 | 5125 | }
|
5110 | 5126 |
|
5111 |
| -static void inline |
| 5127 | +static void |
5112 | 5128 | print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend,
|
5113 | 5129 | const char *title)
|
5114 | 5130 | {
|
@@ -5159,6 +5175,10 @@ print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend,
|
5159 | 5175 | case ZFS_DELEG_EVERYONE:
|
5160 | 5176 | who = gettext("everyone");
|
5161 | 5177 | who_name = NULL;
|
| 5178 | + break; |
| 5179 | + |
| 5180 | + default: |
| 5181 | + assert(who != NULL); |
5162 | 5182 | }
|
5163 | 5183 |
|
5164 | 5184 | prt_who = B_FALSE;
|
@@ -5863,7 +5883,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
|
5863 | 5883 | shared_nfs = zfs_is_shared_nfs(zhp, NULL);
|
5864 | 5884 | shared_smb = zfs_is_shared_smb(zhp, NULL);
|
5865 | 5885 |
|
5866 |
| - if (shared_nfs && shared_smb || |
| 5886 | + if ((shared_nfs && shared_smb) || |
5867 | 5887 | (shared_nfs && strcmp(shareopts, "on") == 0 &&
|
5868 | 5888 | strcmp(smbshareopts, "off") == 0) ||
|
5869 | 5889 | (shared_smb && strcmp(smbshareopts, "on") == 0 &&
|
@@ -6322,7 +6342,7 @@ unshare_unmount(int op, int argc, char **argv)
|
6322 | 6342 | */
|
6323 | 6343 | struct mnttab entry;
|
6324 | 6344 | uu_avl_pool_t *pool;
|
6325 |
| - uu_avl_t *tree; |
| 6345 | + uu_avl_t *tree = NULL; |
6326 | 6346 | unshare_unmount_node_t *node;
|
6327 | 6347 | uu_avl_index_t idx;
|
6328 | 6348 | uu_avl_walk_t *walk;
|
@@ -6752,7 +6772,7 @@ zfs_do_diff(int argc, char **argv)
|
6752 | 6772 | if (copy == NULL)
|
6753 | 6773 | usage(B_FALSE);
|
6754 | 6774 |
|
6755 |
| - if (atp = strchr(copy, '@')) |
| 6775 | + if ((atp = strchr(copy, '@')) != NULL) |
6756 | 6776 | *atp = '\0';
|
6757 | 6777 |
|
6758 | 6778 | if ((zhp = zfs_open(g_zfs, copy, ZFS_TYPE_FILESYSTEM)) == NULL)
|
|
0 commit comments