mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-09 01:18:39 +03:00
Using enum types for enums
alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
This commit is contained in:
parent
7ed8790301
commit
f2cbcb027e
@ -494,7 +494,7 @@ static percent_range_t _combine_percent(percent_t a, percent_t b,
|
||||
if (a == PERCENT_0 && b == PERCENT_0)
|
||||
return PERCENT_0;
|
||||
|
||||
return make_percent(numerator, denominator);
|
||||
return (percent_range_t) make_percent(numerator, denominator);
|
||||
}
|
||||
|
||||
static int _percent_run(struct dev_manager *dm, const char *name,
|
||||
|
@ -68,7 +68,7 @@ static char _default_uuid_prefix[DM_MAX_UUID_PREFIX_LEN + 1] = "LVM-";
|
||||
|
||||
static int _verbose = 0;
|
||||
static int _suspended_dev_counter = 0;
|
||||
static int _name_mangling_mode = -1;
|
||||
static dm_string_mangling_t _name_mangling_mode = DEFAULT_DM_NAME_MANGLING;
|
||||
|
||||
#ifdef HAVE_SELINUX_LABEL_H
|
||||
static struct selabel_handle *_selabel_handle = NULL;
|
||||
|
@ -3614,7 +3614,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
log_error("Unknown name mangling mode");
|
||||
return 0;
|
||||
}
|
||||
dm_set_name_mangling_mode(_int_args[MANGLENAME_ARG]);
|
||||
dm_set_name_mangling_mode((dm_string_mangling_t) _int_args[MANGLENAME_ARG]);
|
||||
}
|
||||
if (ind == NAMEPREFIXES_ARG)
|
||||
_switches[NAMEPREFIXES_ARG]++;
|
||||
|
@ -340,7 +340,7 @@ static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
|
||||
want_contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
|
||||
alloc = want_contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
||||
alloc = arg_uint_value(cmd, alloc_ARG, alloc);
|
||||
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, alloc);
|
||||
|
||||
if (alloc == lv->alloc) {
|
||||
log_error("Allocation policy of logical volume \"%s\" is "
|
||||
|
@ -200,7 +200,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
||||
* versus an additional qualifying argument being added here.
|
||||
*/
|
||||
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0);
|
||||
lp->mirrors_sign = arg_sign_value(cmd, mirrors_ARG, 0);
|
||||
lp->mirrors_sign = arg_sign_value(cmd, mirrors_ARG, SIGN_NONE);
|
||||
}
|
||||
|
||||
lp->alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
|
||||
@ -229,7 +229,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, chunksize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative chunk size is invalid");
|
||||
return 0;
|
||||
}
|
||||
@ -288,7 +288,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
||||
*/
|
||||
|
||||
if (arg_count(cmd, regionsize_ARG)) {
|
||||
if (arg_sign_value(cmd, regionsize_ARG, 0) ==
|
||||
if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) ==
|
||||
SIGN_MINUS) {
|
||||
log_error("Negative regionsize is invalid");
|
||||
return 0;
|
||||
|
@ -321,7 +321,7 @@ static int _read_size_params(struct lvcreate_params *lp,
|
||||
}
|
||||
|
||||
if (arg_count(cmd, extents_ARG)) {
|
||||
if (arg_sign_value(cmd, extents_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, extents_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative number of extents is invalid");
|
||||
return 0;
|
||||
}
|
||||
@ -331,7 +331,7 @@ static int _read_size_params(struct lvcreate_params *lp,
|
||||
|
||||
/* Size returned in kilobyte units; held in sectors */
|
||||
if (arg_count(cmd, size_ARG)) {
|
||||
if (arg_sign_value(cmd, size_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, size_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative size is invalid");
|
||||
return 0;
|
||||
}
|
||||
@ -348,7 +348,7 @@ static int _read_size_params(struct lvcreate_params *lp,
|
||||
log_error("--poolmetadatasize may only be specified when allocating the thin pool.");
|
||||
return 0;
|
||||
}
|
||||
if (arg_sign_value(cmd, poolmetadatasize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative poolmetadatasize is invalid.");
|
||||
return 0;
|
||||
}
|
||||
@ -361,7 +361,7 @@ static int _read_size_params(struct lvcreate_params *lp,
|
||||
log_error("Virtual size in incompatible with thin_pool segment type.");
|
||||
return 0;
|
||||
}
|
||||
if (arg_sign_value(cmd, virtualsize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, virtualsize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative virtual origin size is invalid");
|
||||
return 0;
|
||||
}
|
||||
@ -443,7 +443,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
|
||||
lp->nosync = arg_is_set(cmd, nosync_ARG);
|
||||
|
||||
if (arg_count(cmd, regionsize_ARG)) {
|
||||
if (arg_sign_value(cmd, regionsize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative regionsize is invalid");
|
||||
return 0;
|
||||
}
|
||||
@ -542,7 +542,8 @@ static int _read_activation_params(struct lvcreate_params *lp, struct cmd_contex
|
||||
{
|
||||
unsigned pagesize;
|
||||
|
||||
lp->activate = arg_uint_value(cmd, available_ARG, CHANGE_AY);
|
||||
lp->activate = (activation_change_t)
|
||||
arg_uint_value(cmd, available_ARG, CHANGE_AY);
|
||||
|
||||
if (lp->activate == CHANGE_AN || lp->activate == CHANGE_ALN) {
|
||||
if (lp->zero && !seg_is_thin(lp)) {
|
||||
@ -688,7 +689,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
||||
}
|
||||
log_print("Redundant mirrors argument: default is 0");
|
||||
}
|
||||
if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, mirrors_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Mirrors argument may not be negative");
|
||||
return 0;
|
||||
}
|
||||
@ -743,7 +744,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
||||
if (arg_count(cmd, chunksize_ARG))
|
||||
log_warn("WARNING: Ignoring --chunksize when using an existing pool.");
|
||||
} else if (lp->snapshot || lp->create_thin_pool) {
|
||||
if (arg_sign_value(cmd, chunksize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative chunk size is invalid");
|
||||
return 0;
|
||||
}
|
||||
@ -796,7 +797,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
||||
|
||||
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
||||
|
||||
lp->alloc = arg_uint_value(cmd, alloc_ARG, lp->alloc);
|
||||
lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lp->alloc);
|
||||
|
||||
if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) {
|
||||
log_error("Conflicting contiguous and alloc arguments");
|
||||
|
@ -50,7 +50,7 @@ static int _validate_stripesize(struct cmd_context *cmd,
|
||||
const struct volume_group *vg,
|
||||
struct lvresize_params *lp)
|
||||
{
|
||||
if (arg_sign_value(cmd, stripesize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, stripesize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Stripesize may not be negative.");
|
||||
return 0;
|
||||
}
|
||||
@ -415,7 +415,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
||||
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 1) + 1;
|
||||
else
|
||||
log_warn("Mirrors not supported. Ignoring.");
|
||||
if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, mirrors_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Mirrors argument may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
@ -452,7 +452,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
alloc = arg_uint_value(cmd, alloc_ARG, lv->alloc);
|
||||
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lv->alloc);
|
||||
|
||||
if (lp->size) {
|
||||
if (lp->size % vg->extent_size) {
|
||||
|
@ -310,7 +310,7 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
|
||||
|
||||
parms.aborting = arg_is_set(cmd, abort_ARG);
|
||||
parms.background = background;
|
||||
interval_sign = arg_sign_value(cmd, interval_ARG, 0);
|
||||
interval_sign = arg_sign_value(cmd, interval_ARG, SIGN_NONE);
|
||||
if (interval_sign == SIGN_MINUS)
|
||||
log_error("Argument to --interval cannot be negative");
|
||||
parms.interval = arg_uint_value(cmd, interval_ARG,
|
||||
|
@ -78,7 +78,7 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,
|
||||
release_vg(vg);
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, physicalvolumesize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Physical volume size may not be negative");
|
||||
return 0;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
&pv_name_arg, 0)))
|
||||
goto_out;
|
||||
|
||||
alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
|
||||
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
|
||||
if (alloc == ALLOC_INHERIT)
|
||||
alloc = vg->alloc;
|
||||
|
||||
|
@ -162,7 +162,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, physicalvolumesize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Physical volume size may not be negative");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1257,7 +1257,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
||||
/* Default depends on current locking type */
|
||||
vp_new->clustered = locking_is_clustered();
|
||||
|
||||
if (arg_sign_value(cmd, physicalextentsize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, physicalextentsize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Physical extent size may not be negative");
|
||||
return 1;
|
||||
}
|
||||
@ -1268,12 +1268,12 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, maxlogicalvolumes_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, maxlogicalvolumes_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Max Logical Volumes may not be negative");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, maxphysicalvolumes_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, maxphysicalvolumes_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Max Physical Volumes may not be negative");
|
||||
return 1;
|
||||
}
|
||||
@ -1435,7 +1435,7 @@ int pvcreate_params_validate(struct cmd_context *cmd,
|
||||
if (arg_count(cmd, zero_ARG))
|
||||
pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||
|
||||
if (arg_sign_value(cmd, dataalignment_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, dataalignment_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Physical volume data alignment may not be negative");
|
||||
return 0;
|
||||
}
|
||||
@ -1454,7 +1454,7 @@ int pvcreate_params_validate(struct cmd_context *cmd,
|
||||
pp->data_alignment = 0;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, dataalignmentoffset_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, dataalignmentoffset_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Physical volume data alignment offset may not be negative");
|
||||
return 0;
|
||||
}
|
||||
@ -1472,7 +1472,7 @@ int pvcreate_params_validate(struct cmd_context *cmd,
|
||||
pp->data_alignment_offset = 0;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, metadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Metadata size may not be negative");
|
||||
return 0;
|
||||
}
|
||||
@ -1562,7 +1562,7 @@ int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes, uint32_t *stri
|
||||
|
||||
*stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
|
||||
if (*stripe_size) {
|
||||
if (arg_sign_value(cmd, stripesize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, stripesize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Negative stripesize is invalid");
|
||||
return 0;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
|
||||
{
|
||||
alloc_policy_t alloc;
|
||||
|
||||
alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
|
||||
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
|
||||
|
||||
/* FIXME: make consistent with vg_set_alloc_policy() */
|
||||
if (alloc == vg->alloc) {
|
||||
@ -596,13 +596,13 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (arg_count(cmd, maxphysicalvolumes_ARG) &&
|
||||
arg_sign_value(cmd, maxphysicalvolumes_ARG, 0) == SIGN_MINUS) {
|
||||
arg_sign_value(cmd, maxphysicalvolumes_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("MaxPhysicalVolumes may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, physicalextentsize_ARG) &&
|
||||
arg_sign_value(cmd, physicalextentsize_ARG, 0) == SIGN_MINUS) {
|
||||
arg_sign_value(cmd, physicalextentsize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Physical extent size may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
if (cmd->fmt->features & FMT_MDAS) {
|
||||
if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
|
||||
if (arg_sign_value(cmd, metadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||
log_error("Metadata size may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user