OpenZFS 6931 - lib/libzfs: cleanup gcc warnings

Authored by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>

OpenZFS-issue: https://www.illumos.org/issues/6931
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/88f61de
Closes #5741
This commit is contained in:
George Melikov 2017-02-08 01:02:27 +03:00 committed by Brian Behlendorf
parent bef78122e6
commit 23d70cdef1
8 changed files with 57 additions and 16 deletions

View File

@ -25,6 +25,7 @@
* *
* Portions Copyright 2007 Ramprakash Jelari * Portions Copyright 2007 Ramprakash Jelari
* Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
#include <libintl.h> #include <libintl.h>
@ -132,6 +133,7 @@ changelist_prefix(prop_changelist_t *clp)
case ZFS_PROP_SHARESMB: case ZFS_PROP_SHARESMB:
(void) zfs_unshare_smb(cn->cn_handle, NULL); (void) zfs_unshare_smb(cn->cn_handle, NULL);
break; break;
default: default:
break; break;
} }

View File

@ -28,6 +28,7 @@
* Copyright (c) 2013 Martin Matuska. All rights reserved. * Copyright (c) 2013 Martin Matuska. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc. * Copyright 2016 Nexenta Systems, Inc.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
#include <ctype.h> #include <ctype.h>
@ -80,8 +81,12 @@ zfs_type_to_name(zfs_type_t type)
return (dgettext(TEXT_DOMAIN, "snapshot")); return (dgettext(TEXT_DOMAIN, "snapshot"));
case ZFS_TYPE_VOLUME: case ZFS_TYPE_VOLUME:
return (dgettext(TEXT_DOMAIN, "volume")); return (dgettext(TEXT_DOMAIN, "volume"));
case ZFS_TYPE_POOL:
return (dgettext(TEXT_DOMAIN, "pool"));
case ZFS_TYPE_BOOKMARK:
return (dgettext(TEXT_DOMAIN, "bookmark"));
default: default:
break; assert(!"unhandled zfs_type_t");
} }
return (NULL); return (NULL);
@ -149,7 +154,10 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"reserved disk name")); "reserved disk name"));
break; break;
default: default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"(%d) not defined"), why);
break; break;
} }
} }
@ -827,7 +835,8 @@ libzfs_mnttab_fini(libzfs_handle_t *hdl)
void *cookie = NULL; void *cookie = NULL;
mnttab_node_t *mtn; mnttab_node_t *mtn;
while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie))) { while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie))
!= NULL) {
free(mtn->mtn_mt.mnt_special); free(mtn->mtn_mt.mnt_special);
free(mtn->mtn_mt.mnt_mountp); free(mtn->mtn_mt.mnt_mountp);
free(mtn->mtn_mt.mnt_fstype); free(mtn->mtn_mt.mnt_fstype);
@ -905,7 +914,8 @@ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname)
mnttab_node_t *ret; mnttab_node_t *ret;
find.mtn_mt.mnt_special = (char *)fsname; find.mtn_mt.mnt_special = (char *)fsname;
if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL))) { if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL))
!= NULL) {
avl_remove(&hdl->libzfs_mnttab_cache, ret); avl_remove(&hdl->libzfs_mnttab_cache, ret);
free(ret->mtn_mt.mnt_special); free(ret->mtn_mt.mnt_special);
free(ret->mtn_mt.mnt_mountp); free(ret->mtn_mt.mnt_mountp);
@ -1254,7 +1264,12 @@ badlabel:
"component of '%s' is too long"), "component of '%s' is too long"),
propname); propname);
break; break;
default: default:
zfs_error_aux(hdl,
dgettext(TEXT_DOMAIN,
"(%d) not defined"),
why);
break; break;
} }
(void) zfs_error(hdl, EZFS_BADPROP, errbuf); (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
@ -1374,12 +1389,15 @@ badlabel:
} }
break; break;
case ZFS_PROP_UTF8ONLY: case ZFS_PROP_UTF8ONLY:
chosen_utf = (int)intval; chosen_utf = (int)intval;
break; break;
case ZFS_PROP_NORMALIZE: case ZFS_PROP_NORMALIZE:
chosen_normal = (int)intval; chosen_normal = (int)intval;
break; break;
default: default:
break; break;
} }
@ -1430,6 +1448,7 @@ badlabel:
goto error; goto error;
} }
break; break;
default: default:
break; break;
} }
@ -2076,6 +2095,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
mntopt_on = MNTOPT_NBMAND; mntopt_on = MNTOPT_NBMAND;
mntopt_off = MNTOPT_NONBMAND; mntopt_off = MNTOPT_NONBMAND;
break; break;
default: default:
break; break;
} }
@ -3251,7 +3271,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
* up to the prefixlen-long one. * up to the prefixlen-long one.
*/ */
for (cp = target + prefixlen + 1; for (cp = target + prefixlen + 1;
(cp = strchr(cp, '/')); *cp = '/', cp++) { (cp = strchr(cp, '/')) != NULL; *cp = '/', cp++) {
*cp = '\0'; *cp = '\0';
@ -4021,7 +4041,7 @@ int
zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive, zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
boolean_t force_unmount) boolean_t force_unmount)
{ {
int ret; int ret = 0;
zfs_cmd_t zc = {"\0"}; zfs_cmd_t zc = {"\0"};
char *delim; char *delim;
prop_changelist_t *cl = NULL; prop_changelist_t *cl = NULL;

View File

@ -24,6 +24,7 @@
* Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2015 by Delphix. All rights reserved. * Copyright (c) 2015 by Delphix. All rights reserved.
* Copyright 2016 Joyent, Inc. * Copyright 2016 Joyent, Inc.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
/* /*
@ -345,7 +346,7 @@ write_inuse_diffs(FILE *fp, differ_info_t *di, dmu_diff_record_t *dr)
int err; int err;
for (o = dr->ddr_first; o <= dr->ddr_last; o++) { for (o = dr->ddr_first; o <= dr->ddr_last; o++) {
if ((err = write_inuse_diffs_one(fp, di, o))) if ((err = write_inuse_diffs_one(fp, di, o)) != 0)
return (err); return (err);
} }
return (0); return (0);

View File

@ -23,6 +23,7 @@
* Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
/* /*
@ -708,7 +709,8 @@ zfs_is_shared_proto(zfs_handle_t *zhp, char **where, zfs_share_proto_t proto)
if (!zfs_is_mounted(zhp, &mountpoint)) if (!zfs_is_mounted(zhp, &mountpoint))
return (SHARED_NOT_SHARED); return (SHARED_NOT_SHARED);
if ((rc = is_shared(zhp->zfs_hdl, mountpoint, proto))) { if ((rc = is_shared(zhp->zfs_hdl, mountpoint, proto))
!= SHARED_NOT_SHARED) {
if (where != NULL) if (where != NULL)
*where = mountpoint; *where = mountpoint;
else else

View File

@ -23,6 +23,7 @@
* Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
#include <ctype.h> #include <ctype.h>
@ -180,8 +181,6 @@ char *
zpool_state_to_name(vdev_state_t state, vdev_aux_t aux) zpool_state_to_name(vdev_state_t state, vdev_aux_t aux)
{ {
switch (state) { switch (state) {
default:
break;
case VDEV_STATE_CLOSED: case VDEV_STATE_CLOSED:
case VDEV_STATE_OFFLINE: case VDEV_STATE_OFFLINE:
return (gettext("OFFLINE")); return (gettext("OFFLINE"));
@ -200,6 +199,9 @@ zpool_state_to_name(vdev_state_t state, vdev_aux_t aux)
return (gettext("DEGRADED")); return (gettext("DEGRADED"));
case VDEV_STATE_HEALTHY: case VDEV_STATE_HEALTHY:
return (gettext("ONLINE")); return (gettext("ONLINE"));
default:
break;
} }
return (gettext("UNKNOWN")); return (gettext("UNKNOWN"));
@ -516,8 +518,6 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
* Perform additional checking for specific properties. * Perform additional checking for specific properties.
*/ */
switch (prop) { switch (prop) {
default:
break;
case ZPOOL_PROP_VERSION: case ZPOOL_PROP_VERSION:
if (intval < version || if (intval < version ||
!SPA_VERSION_IS_SUPPORTED(intval)) { !SPA_VERSION_IS_SUPPORTED(intval)) {
@ -679,6 +679,10 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
(void) zfs_error(hdl, EZFS_BADPROP, errbuf); (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error; goto error;
} }
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s'(%d) not defined"), propname, prop);
break; break;
} }
} }
@ -998,6 +1002,10 @@ zpool_name_valid(libzfs_handle_t *hdl, boolean_t isopen, const char *pool)
case NAME_ERR_NO_AT: case NAME_ERR_NO_AT:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"permission set is missing '@'")); "permission set is missing '@'"));
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"(%d) not defined"), why);
break; break;
} }
} }

View File

@ -27,6 +27,7 @@
* All rights reserved * All rights reserved
* Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
#include <assert.h> #include <assert.h>
@ -1325,7 +1326,7 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
pa.pa_parsable = sdd->parsable; pa.pa_parsable = sdd->parsable;
if ((err = pthread_create(&tid, NULL, if ((err = pthread_create(&tid, NULL,
send_progress_thread, &pa))) { send_progress_thread, &pa)) != 0) {
zfs_close(zhp); zfs_close(zhp);
return (err); return (err);
} }
@ -1800,7 +1801,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
if (flags->dedup && !flags->dryrun) { if (flags->dedup && !flags->dryrun) {
featureflags |= (DMU_BACKUP_FEATURE_DEDUP | featureflags |= (DMU_BACKUP_FEATURE_DEDUP |
DMU_BACKUP_FEATURE_DEDUPPROPS); DMU_BACKUP_FEATURE_DEDUPPROPS);
if ((err = socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd))) { if ((err = socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd)) != 0) {
zfs_error_aux(zhp->zfs_hdl, strerror(errno)); zfs_error_aux(zhp->zfs_hdl, strerror(errno));
return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED, return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED,
errbuf)); errbuf));
@ -1808,7 +1809,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
dda.outputfd = outfd; dda.outputfd = outfd;
dda.inputfd = pipefd[1]; dda.inputfd = pipefd[1];
dda.dedup_hdl = zhp->zfs_hdl; dda.dedup_hdl = zhp->zfs_hdl;
if ((err = pthread_create(&tid, NULL, cksummer, &dda))) { if ((err = pthread_create(&tid, NULL, cksummer, &dda)) != 0) {
(void) close(pipefd[0]); (void) close(pipefd[0]);
(void) close(pipefd[1]); (void) close(pipefd[1]);
zfs_error_aux(zhp->zfs_hdl, strerror(errno)); zfs_error_aux(zhp->zfs_hdl, strerror(errno));

View File

@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
/* /*
@ -1465,6 +1466,10 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp,
case ZPROP_SRC_RECEIVED: case ZPROP_SRC_RECEIVED:
str = "received"; str = "received";
break; break;
default:
str = NULL;
assert(!"unhandled zprop_source_t");
} }
break; break;

View File

@ -22,6 +22,7 @@
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/ */
#include <sys/zfs_context.h> #include <sys/zfs_context.h>
@ -181,8 +182,9 @@ zfs_deleg_verify_nvlist(nvlist_t *nvp)
nvpair_name(perm_name)); nvpair_name(perm_name));
if (error) if (error)
return (-1); return (-1);
} while ((perm_name = nvlist_next_nvpair(perms, perm_name))); } while ((perm_name = nvlist_next_nvpair(perms, perm_name))
} while ((who = nvlist_next_nvpair(nvp, who))); != NULL);
} while ((who = nvlist_next_nvpair(nvp, who)) != NULL);
return (0); return (0);
} }