Skip to content

Commit

Permalink
OpenZFS 6550 - cmd/zfs: cleanup gcc warnings
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Andy Stormont <[email protected]>
Approved by: Dan McDonald <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>

OpenZFS-issue: https://www.illumos.org/issues/6550
OpenZFS-commit: openzfs/openzfs@c16bcc4
Closes openzfs#5591
  • Loading branch information
behlendorf authored Jan 17, 2017
1 parent 8e89657 commit 648a09a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
38 changes: 23 additions & 15 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>.
*/

#include <assert.h>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -2353,6 +2354,7 @@ us_compare(const void *larg, const void *rarg, void *unused)
if (rv64 != lv64)
rc = (rv64 < lv64) ? 1 : -1;
break;

default:
break;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -4617,6 +4620,7 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
if (g)
nice_name = g->gr_name;
break;

default:
break;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 648a09a

Please sign in to comment.