mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Tidy some uses of arg_count and introduce arg_is_set.
This commit is contained in:
parent
badfe1cfd2
commit
a8fb89adaf
@ -1,5 +1,6 @@
|
||||
Version 2.02.55 -
|
||||
===================================
|
||||
Tidy some uses of arg_count and introduce arg_is_set.
|
||||
Export outnl and indent functions for modules.
|
||||
Flush stdout after yes/no prompt.
|
||||
Update vgsplit and vgcreate to use vg_set_clustered.
|
||||
|
@ -1,5 +1,6 @@
|
||||
Version 1.02.40 -
|
||||
===================================
|
||||
Fix hash lookup segfault when keys compared are different lengths.
|
||||
|
||||
Version 1.02.39 - 26th October 2009
|
||||
===================================
|
||||
|
@ -17,10 +17,7 @@
|
||||
|
||||
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
const char *file = NULL;
|
||||
|
||||
if (arg_count(cmd, file_ARG))
|
||||
file = arg_str_value(cmd, file_ARG, "");
|
||||
const char *file = arg_str_value(cmd, file_ARG, NULL);
|
||||
|
||||
if (!write_config_file(cmd->cft, file, argc, argv)) {
|
||||
stack;
|
||||
|
@ -129,9 +129,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
||||
lp->mirrors_sign = arg_sign_value(cmd, mirrors_ARG, 0);
|
||||
}
|
||||
|
||||
lp->alloc = ALLOC_INHERIT;
|
||||
if (arg_count(cmd, alloc_ARG))
|
||||
lp->alloc = arg_uint_value(cmd, alloc_ARG, lp->alloc);
|
||||
lp->alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
|
||||
|
||||
if (lp->snapshot) {
|
||||
if (arg_count(cmd, regionsize_ARG)) {
|
||||
|
@ -33,8 +33,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
|
||||
char **argv = *pargv, *ptr;
|
||||
char *vg_name;
|
||||
|
||||
if (arg_count(cmd, name_ARG))
|
||||
lp->lv_name = arg_value(cmd, name_ARG);
|
||||
lp->lv_name = arg_str_value(cmd, name_ARG, NULL);
|
||||
|
||||
if (lp->snapshot && !arg_count(cmd, virtualsize_ARG)) {
|
||||
if (!argc) {
|
||||
@ -347,7 +346,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
|
||||
|
||||
log_verbose("Setting logging type to %s", mirrorlog);
|
||||
|
||||
lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
|
||||
lp->nosync = arg_is_set(cmd, nosync_ARG);
|
||||
|
||||
if (arg_count(cmd, regionsize_ARG)) {
|
||||
if (arg_sign_value(cmd, regionsize_ARG, 0) == SIGN_MINUS) {
|
||||
@ -521,10 +520,8 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
||||
/*
|
||||
* Permissions.
|
||||
*/
|
||||
if (arg_count(cmd, permission_ARG))
|
||||
lp->permission = arg_uint_value(cmd, permission_ARG, 0);
|
||||
else
|
||||
lp->permission = LVM_READ | LVM_WRITE;
|
||||
lp->permission = arg_uint_value(cmd, permission_ARG,
|
||||
LVM_READ | LVM_WRITE);
|
||||
|
||||
/* Must not zero read only volume */
|
||||
if (!(lp->permission & LVM_WRITE))
|
||||
@ -558,11 +555,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, addtag_ARG) &&
|
||||
!(lp->tag = arg_str_value(cmd, addtag_ARG, NULL))) {
|
||||
log_error("Failed to get tag");
|
||||
return 0;
|
||||
}
|
||||
lp->tag = arg_str_value(cmd, addtag_ARG, NULL);
|
||||
|
||||
lcp->pv_count = argc;
|
||||
lcp->pvs = argv;
|
||||
|
@ -54,61 +54,58 @@ static struct arg _the_args[ARG_COUNT + 1] = {
|
||||
static struct cmdline_context _cmdline;
|
||||
|
||||
/* Command line args */
|
||||
/* FIXME: struct cmd_context * is unnecessary (large # files ) */
|
||||
/* FIXME: Move static _the_args into cmd? */
|
||||
unsigned arg_count(const struct cmd_context *cmd __attribute((unused)), int a)
|
||||
{
|
||||
return _the_args[a].count;
|
||||
}
|
||||
|
||||
unsigned arg_is_set(const struct cmd_context *cmd, int a)
|
||||
{
|
||||
return arg_count(cmd, a) ? 1 : 0;
|
||||
}
|
||||
|
||||
const char *arg_value(struct cmd_context *cmd __attribute((unused)), int a)
|
||||
{
|
||||
return _the_args[a].value;
|
||||
}
|
||||
|
||||
const char *arg_str_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const char *def)
|
||||
const char *arg_str_value(struct cmd_context *cmd, int a, const char *def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].value : def;
|
||||
}
|
||||
|
||||
int32_t arg_int_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const int32_t def)
|
||||
int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].i_value : def;
|
||||
}
|
||||
|
||||
uint32_t arg_uint_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const uint32_t def)
|
||||
uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].ui_value : def;
|
||||
}
|
||||
|
||||
int64_t arg_int64_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const int64_t def)
|
||||
int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].i64_value : def;
|
||||
}
|
||||
|
||||
uint64_t arg_uint64_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const uint64_t def)
|
||||
uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].ui64_value : def;
|
||||
}
|
||||
|
||||
const void *arg_ptr_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const void *def)
|
||||
const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].ptr : def;
|
||||
}
|
||||
|
||||
sign_t arg_sign_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const sign_t def)
|
||||
sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].sign : def;
|
||||
}
|
||||
|
||||
percent_t arg_percent_value(struct cmd_context *cmd __attribute((unused)),
|
||||
int a, const percent_t def)
|
||||
percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? _the_args[a].percent : def;
|
||||
}
|
||||
|
@ -240,8 +240,8 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
lp->resizefs = arg_count(cmd, resizefs_ARG) ? 1 : 0;
|
||||
lp->nofsck = arg_count(cmd, nofsck_ARG) ? 1 : 0;
|
||||
lp->resizefs = arg_is_set(cmd, resizefs_ARG);
|
||||
lp->nofsck = arg_is_set(cmd, nofsck_ARG);
|
||||
|
||||
if (!argc) {
|
||||
log_error("Please provide the logical volume name");
|
||||
|
@ -239,7 +239,7 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
|
||||
{
|
||||
struct daemon_parms parms;
|
||||
|
||||
parms.aborting = arg_count(cmd, abort_ARG) ? 1 : 0;
|
||||
parms.aborting = arg_is_set(cmd, abort_ARG);
|
||||
parms.background = background;
|
||||
parms.interval = arg_uint_value(cmd, interval_ARG, DEFAULT_INTERVAL);
|
||||
parms.progress_display = 1;
|
||||
|
@ -608,6 +608,5 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
return pvmove_poll(cmd, pv_name,
|
||||
arg_count(cmd, background_ARG) ? 1U : 0);
|
||||
return pvmove_poll(cmd, pv_name, arg_is_set(cmd, background_ARG));
|
||||
}
|
||||
|
@ -327,11 +327,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
}
|
||||
|
||||
/* -O overrides default sort settings */
|
||||
if (arg_count(cmd, sort_ARG))
|
||||
keys = arg_str_value(cmd, sort_ARG, "");
|
||||
keys = arg_str_value(cmd, sort_ARG, keys);
|
||||
|
||||
if (arg_count(cmd, separator_ARG))
|
||||
separator = arg_str_value(cmd, separator_ARG, " ");
|
||||
separator = arg_str_value(cmd, separator_ARG, separator);
|
||||
if (arg_count(cmd, separator_ARG))
|
||||
aligned = 0;
|
||||
if (arg_count(cmd, aligned_ARG))
|
||||
|
@ -153,7 +153,8 @@ int alloc_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int readahead_arg(struct cmd_context *cmd, struct arg *a);
|
||||
|
||||
/* we use the enums to access the switches */
|
||||
unsigned int arg_count(const struct cmd_context *cmd, int a);
|
||||
unsigned arg_count(const struct cmd_context *cmd, int a);
|
||||
unsigned arg_is_set(const struct cmd_context *cmd, int a);
|
||||
const char *arg_value(struct cmd_context *cmd, int a);
|
||||
const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
|
||||
int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
|
||||
|
Loading…
Reference in New Issue
Block a user