Skip to content

Commit c16bcc4

Browse files
ikozhukhovahrens
authored andcommitted
6550 cmd/zfs: cleanup gcc warnings
Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Andy Stormont <astormont@racktopsystems.com> Approved by: Dan McDonald <danmcd@omniti.com>
1 parent b327cd3 commit c16bcc4

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

usr/src/cmd/zfs/Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#
2424
# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
2525
# Copyright (c) 2012 by Delphix. All rights reserved.
26+
# Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
2627
#
2728

2829
PROG= zfs
@@ -53,12 +54,6 @@ $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
5354
LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2
5455
LINTFLAGS64 += -xerroff=E_NAME_DEF_NOT_USED2
5556

56-
CERRWARN += -_gcc=-Wno-switch
57-
CERRWARN += -_gcc=-Wno-type-limits
58-
CERRWARN += -_gcc=-Wno-parentheses
59-
CERRWARN += -_gcc=-Wno-uninitialized
60-
CERRWARN += -_gcc=-Wno-old-style-declaration
61-
6257
ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%)
6358
USRLIBFSTYPELINKS = $(LINKPROGS:%=$(USRLIBFSTYPE)/%)
6459
ROOTETCFSTYPELINKS = $(LINKPROGS:%=$(ROOTETCFSTYPE)/%)

usr/src/cmd/zfs/zfs_main.c

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* Copyright (c) 2013 Steven Hartland. All rights reserved.
2828
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
2929
* Copyright (c) 2014 Integros [integros.com]
30+
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
3031
*/
3132

3233
#include <assert.h>
@@ -731,7 +732,7 @@ zfs_do_create(int argc, char **argv)
731732
{
732733
zfs_type_t type = ZFS_TYPE_FILESYSTEM;
733734
zfs_handle_t *zhp = NULL;
734-
uint64_t volsize;
735+
uint64_t volsize = 0;
735736
int c;
736737
boolean_t noreserve = B_FALSE;
737738
boolean_t bflag = B_FALSE;
@@ -817,14 +818,14 @@ zfs_do_create(int argc, char **argv)
817818

818819
if (type == ZFS_TYPE_VOLUME && !noreserve) {
819820
zpool_handle_t *zpool_handle;
820-
nvlist_t *real_props;
821+
nvlist_t *real_props = NULL;
821822
uint64_t spa_version;
822823
char *p;
823824
zfs_prop_t resv_prop;
824825
char *strval;
825826
char msg[1024];
826827

827-
if (p = strchr(argv[0], '/'))
828+
if ((p = strchr(argv[0], '/')) != NULL)
828829
*p = '\0';
829830
zpool_handle = zpool_open(g_zfs, argv[0]);
830831
if (p != NULL)
@@ -2331,6 +2332,9 @@ us_compare(const void *larg, const void *rarg, void *unused)
23312332
if (rv64 != lv64)
23322333
rc = (rv64 < lv64) ? 1 : -1;
23332334
break;
2335+
2336+
default:
2337+
break;
23342338
}
23352339

23362340
if (rc != 0) {
@@ -2386,7 +2390,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
23862390
nvlist_t *props;
23872391
us_node_t *n;
23882392
zfs_sort_column_t *sortcol = cb->cb_sortcol;
2389-
unsigned type;
2393+
unsigned type = 0;
23902394
const char *typestr;
23912395
size_t namelen;
23922396
size_t typelen;
@@ -3893,7 +3897,7 @@ zfs_do_send(int argc, char **argv)
38933897
static int
38943898
zfs_do_receive(int argc, char **argv)
38953899
{
3896-
int c, err;
3900+
int c, err = 0;
38973901
recvflags_t flags = { 0 };
38983902
boolean_t abort_resumable = B_FALSE;
38993903

@@ -4153,7 +4157,7 @@ deleg_perm_type(zfs_deleg_note_t note)
41534157
}
41544158
}
41554159

4156-
static int inline
4160+
static int
41574161
who_type2weight(zfs_deleg_who_type_t who_type)
41584162
{
41594163
int res;
@@ -4373,7 +4377,7 @@ fs_perm_fini(fs_perm_t *fsperm)
43734377
uu_avl_destroy(fsperm->fsp_uge_avl);
43744378
}
43754379

4376-
static void inline
4380+
static void
43774381
set_deleg_perm_node(uu_avl_t *avl, deleg_perm_node_t *node,
43784382
zfs_deleg_who_type_t who_type, const char *name, char locality)
43794383
{
@@ -4441,7 +4445,7 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
44414445
nvlist_t *nvl2 = NULL;
44424446
const char *name = nvpair_name(nvp);
44434447
uu_avl_t *avl = NULL;
4444-
uu_avl_pool_t *avl_pool;
4448+
uu_avl_pool_t *avl_pool = NULL;
44454449
zfs_deleg_who_type_t perm_type = name[0];
44464450
char perm_locality = name[1];
44474451
const char *perm_name = name + 3;
@@ -4470,6 +4474,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
44704474
avl_pool = fspset->fsps_who_perm_avl_pool;
44714475
avl = fsperm->fsp_uge_avl;
44724476
break;
4477+
4478+
default:
4479+
assert(!"unhandled zfs_deleg_who_type_t");
44734480
}
44744481

44754482
if (is_set) {
@@ -4505,6 +4512,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
45054512
if (g)
45064513
nice_name = g->gr_name;
45074514
break;
4515+
4516+
default:
4517+
break;
45084518
}
45094519

45104520
if (nice_name != NULL)
@@ -4773,11 +4783,12 @@ parse_allow_args(int argc, char **argv, boolean_t un, struct allow_opts *opts)
47734783
allow_usage(un, B_FALSE,
47744784
gettext("-u, -g, and -e are mutually exclusive\n"));
47754785

4776-
if (opts->prt_usage)
4786+
if (opts->prt_usage) {
47774787
if (argc == 0 && all_sum == 0)
47784788
allow_usage(un, B_TRUE, NULL);
47794789
else
47804790
usage(B_FALSE);
4791+
}
47814792

47824793
if (opts->set) {
47834794
if (csuge_sum > 1)
@@ -4826,8 +4837,8 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
48264837
int i;
48274838
char ld[2] = { '\0', '\0' };
48284839
char who_buf[ZFS_MAXNAMELEN+32];
4829-
char base_type;
4830-
char set_type;
4840+
char base_type = '\0';
4841+
char set_type = '\0';
48314842
nvlist_t *base_nvl = NULL;
48324843
nvlist_t *set_nvl = NULL;
48334844
nvlist_t *nvl;
@@ -4876,6 +4887,10 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
48764887
ld[0] = ZFS_DELEG_LOCAL;
48774888
if (descend)
48784889
ld[1] = ZFS_DELEG_DESCENDENT;
4890+
break;
4891+
4892+
default:
4893+
assert(set_type != '\0' && base_type != '\0');
48794894
}
48804895

48814896
if (perms != NULL) {
@@ -4980,7 +4995,7 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp)
49804995

49814996
while (curr < end) {
49824997
const char *who;
4983-
zfs_deleg_who_type_t who_type;
4998+
zfs_deleg_who_type_t who_type = ZFS_DELEG_WHO_UNKNOWN;
49844999
char *endch;
49855000
char *delim = strchr(curr, ',');
49865001
char errbuf[256];
@@ -5030,12 +5045,13 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp)
50305045
p = getpwuid(rid);
50315046
}
50325047

5033-
if (p == NULL)
5048+
if (p == NULL) {
50345049
if (*endch != '\0') {
50355050
g = getgrnam(curr);
50365051
} else {
50375052
g = getgrgid(rid);
50385053
}
5054+
}
50395055

50405056
if (p != NULL) {
50415057
who_type = ZFS_DELEG_USER;
@@ -5108,7 +5124,7 @@ print_set_creat_perms(uu_avl_t *who_avl)
51085124
}
51095125
}
51105126

5111-
static void inline
5127+
static void
51125128
print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend,
51135129
const char *title)
51145130
{
@@ -5159,6 +5175,10 @@ print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend,
51595175
case ZFS_DELEG_EVERYONE:
51605176
who = gettext("everyone");
51615177
who_name = NULL;
5178+
break;
5179+
5180+
default:
5181+
assert(who != NULL);
51625182
}
51635183

51645184
prt_who = B_FALSE;
@@ -5863,7 +5883,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
58635883
shared_nfs = zfs_is_shared_nfs(zhp, NULL);
58645884
shared_smb = zfs_is_shared_smb(zhp, NULL);
58655885

5866-
if (shared_nfs && shared_smb ||
5886+
if ((shared_nfs && shared_smb) ||
58675887
(shared_nfs && strcmp(shareopts, "on") == 0 &&
58685888
strcmp(smbshareopts, "off") == 0) ||
58695889
(shared_smb && strcmp(smbshareopts, "on") == 0 &&
@@ -6322,7 +6342,7 @@ unshare_unmount(int op, int argc, char **argv)
63226342
*/
63236343
struct mnttab entry;
63246344
uu_avl_pool_t *pool;
6325-
uu_avl_t *tree;
6345+
uu_avl_t *tree = NULL;
63266346
unshare_unmount_node_t *node;
63276347
uu_avl_index_t idx;
63286348
uu_avl_walk_t *walk;
@@ -6752,7 +6772,7 @@ zfs_do_diff(int argc, char **argv)
67526772
if (copy == NULL)
67536773
usage(B_FALSE);
67546774

6755-
if (atp = strchr(copy, '@'))
6775+
if ((atp = strchr(copy, '@')) != NULL)
67566776
*atp = '\0';
67576777

67586778
if ((zhp = zfs_open(g_zfs, copy, ZFS_TYPE_FILESYSTEM)) == NULL)

usr/src/uts/common/sys/fs/zfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ typedef enum dmu_objset_type {
7878
* the property table in usr/src/common/zfs/zfs_prop.c.
7979
*/
8080
typedef enum {
81-
ZFS_PROP_TYPE,
81+
ZFS_PROP_BAD = -1,
82+
ZFS_PROP_TYPE = 0,
8283
ZFS_PROP_CREATION,
8384
ZFS_PROP_USED,
8485
ZFS_PROP_AVAILABLE,

0 commit comments

Comments
 (0)