Correct compilation errors reported by GCC 10/11
New `zfs_type_t` value `ZFS_TYPE_INVALID` is introduced. Variable initialization is now possible to make GCC happy. Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: szubersk <szuberskidamian@gmail.com> Closes #12167 Closes #13103
This commit is contained in:
parent
e41013078a
commit
806739f991
|
@ -453,23 +453,21 @@ zfs_for_each(int argc, char **argv, int flags, zfs_type_t types,
|
||||||
cb.cb_flags |= ZFS_ITER_RECURSE;
|
cb.cb_flags |= ZFS_ITER_RECURSE;
|
||||||
ret = zfs_iter_root(g_zfs, zfs_callback, &cb);
|
ret = zfs_iter_root(g_zfs, zfs_callback, &cb);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
zfs_handle_t *zhp = NULL;
|
||||||
zfs_handle_t *zhp;
|
zfs_type_t argtype = types;
|
||||||
zfs_type_t argtype;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're recursive, then we always allow filesystems as
|
* If we're recursive, then we always allow filesystems as
|
||||||
* arguments. If we also are interested in snapshots or
|
* arguments. If we also are interested in snapshots or
|
||||||
* bookmarks, then we can take volumes as well.
|
* bookmarks, then we can take volumes as well.
|
||||||
*/
|
*/
|
||||||
argtype = types;
|
|
||||||
if (flags & ZFS_ITER_RECURSE) {
|
if (flags & ZFS_ITER_RECURSE) {
|
||||||
argtype |= ZFS_TYPE_FILESYSTEM;
|
argtype |= ZFS_TYPE_FILESYSTEM;
|
||||||
if (types & (ZFS_TYPE_SNAPSHOT | ZFS_TYPE_BOOKMARK))
|
if (types & (ZFS_TYPE_SNAPSHOT | ZFS_TYPE_BOOKMARK))
|
||||||
argtype |= ZFS_TYPE_VOLUME;
|
argtype |= ZFS_TYPE_VOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
if (flags & ZFS_ITER_ARGS_CAN_BE_PATHS) {
|
if (flags & ZFS_ITER_ARGS_CAN_BE_PATHS) {
|
||||||
zhp = zfs_path_to_zhandle(g_zfs, argv[i],
|
zhp = zfs_path_to_zhandle(g_zfs, argv[i],
|
||||||
argtype);
|
argtype);
|
||||||
|
|
|
@ -278,7 +278,7 @@ get_vdev_name(nvlist_t *nvroot, const char *parent_name)
|
||||||
vdev_type);
|
vdev_type);
|
||||||
} else {
|
} else {
|
||||||
(void) snprintf(vdev_name, sizeof (vdev_name),
|
(void) snprintf(vdev_name, sizeof (vdev_name),
|
||||||
"%s/%s-%llu",
|
"%.220s/%s-%llu",
|
||||||
parent_name, vdev_type, (u_longlong_t)vdev_id);
|
parent_name, vdev_type, (u_longlong_t)vdev_id);
|
||||||
}
|
}
|
||||||
return (vdev_name);
|
return (vdev_name);
|
||||||
|
|
|
@ -50,6 +50,7 @@ extern "C" {
|
||||||
* combined into masks that can be passed to various functions.
|
* combined into masks that can be passed to various functions.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
ZFS_TYPE_INVALID = 0,
|
||||||
ZFS_TYPE_FILESYSTEM = (1 << 0),
|
ZFS_TYPE_FILESYSTEM = (1 << 0),
|
||||||
ZFS_TYPE_SNAPSHOT = (1 << 1),
|
ZFS_TYPE_SNAPSHOT = (1 << 1),
|
||||||
ZFS_TYPE_VOLUME = (1 << 2),
|
ZFS_TYPE_VOLUME = (1 << 2),
|
||||||
|
|
|
@ -3972,13 +3972,10 @@ zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
|
||||||
/* do the clone */
|
/* do the clone */
|
||||||
|
|
||||||
if (props) {
|
if (props) {
|
||||||
zfs_type_t type;
|
zfs_type_t type = ZFS_TYPE_FILESYSTEM;
|
||||||
|
|
||||||
if (ZFS_IS_VOLUME(zhp)) {
|
if (ZFS_IS_VOLUME(zhp))
|
||||||
type = ZFS_TYPE_VOLUME;
|
type = ZFS_TYPE_VOLUME;
|
||||||
} else {
|
|
||||||
type = ZFS_TYPE_FILESYSTEM;
|
|
||||||
}
|
|
||||||
if ((props = zfs_valid_proplist(hdl, type, props, zoned,
|
if ((props = zfs_valid_proplist(hdl, type, props, zoned,
|
||||||
zhp, zhp->zpool_hdl, B_TRUE, errbuf)) == NULL)
|
zhp, zhp->zpool_hdl, B_TRUE, errbuf)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
|
@ -807,8 +807,9 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
|
||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
int error = errno;
|
int error = errno;
|
||||||
|
|
||||||
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
|
(void) snprintf(errbuf, sizeof (errbuf), "%s '%s'",
|
||||||
"warning: cannot send '%s'"), zhp->zfs_name);
|
dgettext(TEXT_DOMAIN, "warning: cannot send"),
|
||||||
|
zhp->zfs_name);
|
||||||
|
|
||||||
if (debugnv != NULL) {
|
if (debugnv != NULL) {
|
||||||
fnvlist_add_uint64(thisdbg, "error", error);
|
fnvlist_add_uint64(thisdbg, "error", error);
|
||||||
|
@ -4196,7 +4197,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||||
nvlist_t *rcvprops = NULL; /* props received from the send stream */
|
nvlist_t *rcvprops = NULL; /* props received from the send stream */
|
||||||
nvlist_t *oxprops = NULL; /* override (-o) and exclude (-x) props */
|
nvlist_t *oxprops = NULL; /* override (-o) and exclude (-x) props */
|
||||||
nvlist_t *origprops = NULL; /* original props (if destination exists) */
|
nvlist_t *origprops = NULL; /* original props (if destination exists) */
|
||||||
zfs_type_t type;
|
zfs_type_t type = ZFS_TYPE_INVALID;
|
||||||
boolean_t toplevel = B_FALSE;
|
boolean_t toplevel = B_FALSE;
|
||||||
boolean_t zoned = B_FALSE;
|
boolean_t zoned = B_FALSE;
|
||||||
boolean_t hastoken = B_FALSE;
|
boolean_t hastoken = B_FALSE;
|
||||||
|
|
|
@ -199,7 +199,7 @@ execvpe(const char *name, char * const argv[], char * const envp[])
|
||||||
return (execvPe(name, path, argv, envp));
|
return (execvPe(name, path, argv, envp));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ERRBUFLEN 256
|
#define ERRBUFLEN 1024
|
||||||
|
|
||||||
static __thread char errbuf[ERRBUFLEN];
|
static __thread char errbuf[ERRBUFLEN];
|
||||||
|
|
||||||
|
@ -207,10 +207,10 @@ const char *
|
||||||
libzfs_error_init(int error)
|
libzfs_error_init(int error)
|
||||||
{
|
{
|
||||||
char *msg = errbuf;
|
char *msg = errbuf;
|
||||||
size_t len, msglen = ERRBUFLEN;
|
size_t msglen = sizeof (errbuf);
|
||||||
|
|
||||||
if (modfind("zfs") < 0) {
|
if (modfind("zfs") < 0) {
|
||||||
len = snprintf(msg, msglen, dgettext(TEXT_DOMAIN,
|
size_t len = snprintf(msg, msglen, dgettext(TEXT_DOMAIN,
|
||||||
"Failed to load %s module: "), ZFS_KMOD);
|
"Failed to load %s module: "), ZFS_KMOD);
|
||||||
msg += len;
|
msg += len;
|
||||||
msglen -= len;
|
msglen -= len;
|
||||||
|
@ -285,7 +285,6 @@ zfs_jail(zfs_handle_t *zhp, int jailid, int attach)
|
||||||
{
|
{
|
||||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
char errbuf[1024];
|
|
||||||
unsigned long cmd;
|
unsigned long cmd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -314,6 +313,10 @@ zfs_jail(zfs_handle_t *zhp, int jailid, int attach)
|
||||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||||
"vdevs can not be jailed"));
|
"vdevs can not be jailed"));
|
||||||
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
|
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
|
||||||
|
case ZFS_TYPE_INVALID:
|
||||||
|
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||||
|
"invalid zfs_type_t: ZFS_TYPE_INVALID"));
|
||||||
|
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
|
||||||
case ZFS_TYPE_POOL:
|
case ZFS_TYPE_POOL:
|
||||||
case ZFS_TYPE_FILESYSTEM:
|
case ZFS_TYPE_FILESYSTEM:
|
||||||
/* OK */
|
/* OK */
|
||||||
|
|
|
@ -754,6 +754,9 @@ no_dev:
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
#else
|
#else
|
||||||
|
(void) path;
|
||||||
|
(void) ds;
|
||||||
|
(void) wholedisk;
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,8 @@ get_objset_type(dsl_dataset_t *ds, zfs_type_t *type)
|
||||||
static int
|
static int
|
||||||
get_objset_type_name(dsl_dataset_t *ds, char *str)
|
get_objset_type_name(dsl_dataset_t *ds, char *str)
|
||||||
{
|
{
|
||||||
int error;
|
zfs_type_t type = ZFS_TYPE_INVALID;
|
||||||
zfs_type_t type;
|
int error = get_objset_type(ds, &type);
|
||||||
error = get_objset_type(ds, &type);
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -230,7 +229,7 @@ get_special_prop(lua_State *state, dsl_dataset_t *ds, const char *dsname,
|
||||||
char *strval = kmem_alloc(ZAP_MAXVALUELEN, KM_SLEEP);
|
char *strval = kmem_alloc(ZAP_MAXVALUELEN, KM_SLEEP);
|
||||||
char setpoint[ZFS_MAX_DATASET_NAME_LEN] =
|
char setpoint[ZFS_MAX_DATASET_NAME_LEN] =
|
||||||
"Internal error - setpoint not determined";
|
"Internal error - setpoint not determined";
|
||||||
zfs_type_t ds_type = -1;
|
zfs_type_t ds_type = ZFS_TYPE_INVALID;
|
||||||
zprop_type_t prop_type = zfs_prop_get_type(zfs_prop);
|
zprop_type_t prop_type = zfs_prop_get_type(zfs_prop);
|
||||||
(void) get_objset_type(ds, &ds_type);
|
(void) get_objset_type(ds, &ds_type);
|
||||||
|
|
||||||
|
@ -497,8 +496,7 @@ get_zap_prop(lua_State *state, dsl_dataset_t *ds, zfs_prop_t zfs_prop)
|
||||||
boolean_t
|
boolean_t
|
||||||
prop_valid_for_ds(dsl_dataset_t *ds, zfs_prop_t zfs_prop)
|
prop_valid_for_ds(dsl_dataset_t *ds, zfs_prop_t zfs_prop)
|
||||||
{
|
{
|
||||||
int error;
|
zfs_type_t zfs_type = ZFS_TYPE_INVALID;
|
||||||
zfs_type_t zfs_type;
|
|
||||||
|
|
||||||
/* properties not supported */
|
/* properties not supported */
|
||||||
if ((zfs_prop == ZFS_PROP_ISCSIOPTIONS) ||
|
if ((zfs_prop == ZFS_PROP_ISCSIOPTIONS) ||
|
||||||
|
@ -509,7 +507,7 @@ prop_valid_for_ds(dsl_dataset_t *ds, zfs_prop_t zfs_prop)
|
||||||
if ((zfs_prop == ZFS_PROP_ORIGIN) && (!dsl_dir_is_clone(ds->ds_dir)))
|
if ((zfs_prop == ZFS_PROP_ORIGIN) && (!dsl_dir_is_clone(ds->ds_dir)))
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
|
|
||||||
error = get_objset_type(ds, &zfs_type);
|
int error = get_objset_type(ds, &zfs_type);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
return (zfs_prop_valid_for_type(zfs_prop, zfs_type, B_FALSE));
|
return (zfs_prop_valid_for_type(zfs_prop, zfs_type, B_FALSE));
|
||||||
|
|
Loading…
Reference in New Issue