summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2011-02-18 14:47:28 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2011-02-18 14:47:28 +0000
commitaec211541073d107668cfa404970589c7dced120 (patch)
treea9553044dd34e8ad676338c18659affb2f1fe7f2 /tools
parent2f321615f22a9fef2eaa0258d62c49212f52a8b0 (diff)
downloadlvm2-aec211541073d107668cfa404970589c7dced120.tar.gz
lvm2-aec211541073d107668cfa404970589c7dced120.tar.xz
lvm2-aec211541073d107668cfa404970589c7dced120.zip
Const fixing
Fixing some const warnings - with API change in: int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names, Change is needed - as lvm2api expects const behaviour here. So vg_extend() is doing local strdup for unescaping. skip_dev_dir return const char* from const char* vg_name. Rest of the patch is cleanup of related warnings. Also using dm_report_filed_string() API change to simplify casting in _string_disp and _lvname_disp.
Diffstat (limited to 'tools')
-rw-r--r--tools/lvcreate.c2
-rw-r--r--tools/reporter.c4
-rw-r--r--tools/toollib.c10
-rw-r--r--tools/toollib.h4
-rw-r--r--tools/vgcfgrestore.c2
-rw-r--r--tools/vgcreate.c2
-rw-r--r--tools/vgextend.c4
-rw-r--r--tools/vgmerge.c2
-rw-r--r--tools/vgreduce.c2
-rw-r--r--tools/vgrename.c2
-rw-r--r--tools/vgsplit.c2
11 files changed, 18 insertions, 18 deletions
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 70164171..d1abdf7b 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -31,7 +31,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
{
int argc = *pargc;
char **argv = *pargv, *ptr;
- char *vg_name;
+ const char *vg_name;
lp->lv_name = arg_str_value(cmd, name_ARG, NULL);
diff --git a/tools/reporter.c b/tools/reporter.c
index fbd0c274..ebe85e7f 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -61,7 +61,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd,
struct volume_group _free_vg = {
.cmd = cmd,
- .name = (char *)"",
+ .name = "",
};
if (!(_free_vg.vgmem = dm_pool_create("_free_vg", 10240)))
@@ -69,7 +69,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd,
struct logical_volume _free_logical_volume = {
.vg = vg ?: &_free_vg,
- .name = (char *) "",
+ .name = "",
.snapshot = NULL,
.status = VISIBLE_LV,
.major = -1,
diff --git a/tools/toollib.c b/tools/toollib.c
index c85b7f0a..5467a3b7 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -28,7 +28,7 @@ const char *command_name(struct cmd_context *cmd)
/*
* Strip dev_dir if present
*/
-char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
+const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
unsigned *dev_dir_found)
{
const char *dmdir = dm_dir();
@@ -54,7 +54,7 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
*layer) {
log_error("skip_dev_dir: Couldn't split up device name %s",
vg_name);
- return (char *) vg_name;
+ return vg_name;
}
vglv_sz = strlen(vgname) + strlen(lvname) + 2;
if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) ||
@@ -62,7 +62,7 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
*lvname ? "/" : "",
lvname) < 0) {
log_error("vg/lv string alloc failed");
- return (char *) vg_name;
+ return vg_name;
}
return vglv;
}
@@ -76,7 +76,7 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
} else if (dev_dir_found)
*dev_dir_found = 0;
- return (char *) vg_name;
+ return vg_name;
}
/*
@@ -898,7 +898,7 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
*/
char *default_vgname(struct cmd_context *cmd)
{
- char *vg_path;
+ const char *vg_path;
/* Take default VG from environment? */
vg_path = getenv("LVM_VG_NAME");
diff --git a/tools/toollib.h b/tools/toollib.h
index 506945a0..1ef83f68 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -84,8 +84,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
char *default_vgname(struct cmd_context *cmd);
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
-char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
- unsigned *dev_dir_found);
+const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
+ unsigned *dev_dir_found);
/*
* Builds a list of pv's from the names in argv. Used in
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index dc0158f8..1f1ab521 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -17,7 +17,7 @@
int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
{
- char *vg_name = NULL;
+ const char *vg_name = NULL;
if (argc == 1) {
vg_name = skip_dev_dir(cmd, argv[0], NULL);
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 49574f33..62b5ac7b 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -74,7 +74,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
}
/* attach the pv's */
- if (!vg_extend(vg, argc, argv, &pp))
+ if (!vg_extend(vg, argc, (const char* const*)argv, &pp))
goto_bad;
if (vp_new.max_lv != vg->max_lv)
diff --git a/tools/vgextend.c b/tools/vgextend.c
index a0c166b0..5d2b54d7 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -40,7 +40,7 @@ static int _restore_pv(struct volume_group *vg, char *pv_name)
int vgextend(struct cmd_context *cmd, int argc, char **argv)
{
- char *vg_name;
+ const char *vg_name;
struct volume_group *vg = NULL;
int r = ECMD_FAILED;
struct pvcreate_params pp;
@@ -107,7 +107,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
}
/* extend vg */
- if (!vg_extend(vg, argc, argv, &pp))
+ if (!vg_extend(vg, argc, (const char* const*)argv, &pp))
goto_bad;
if (arg_count(cmd, metadataignore_ARG) &&
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 391764f9..adb00a0f 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -163,7 +163,7 @@ bad:
int vgmerge(struct cmd_context *cmd, int argc, char **argv)
{
- char *vg_name_to, *vg_name_from;
+ const char *vg_name_to, *vg_name_from;
int opt = 0;
int ret = 0, ret_max = 0;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 4aa8f01e..5e61cf83 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -457,7 +457,7 @@ bad:
int vgreduce(struct cmd_context *cmd, int argc, char **argv)
{
struct volume_group *vg;
- char *vg_name;
+ const char *vg_name;
int ret = ECMD_FAILED;
int fixed = 1;
int repairing = arg_count(cmd, removemissing_ARG);
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 7a4e730e..2f83fc63 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -63,7 +63,7 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path,
int found_id = 0;
struct dm_list *vgids;
struct str_list *sl;
- char *vg_name_new;
+ const char *vg_name_new;
const char *vgid = NULL, *vg_name, *vg_name_old;
char old_path[NAME_LEN], new_path[NAME_LEN];
struct volume_group *vg = NULL;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index bd2f0ab3..b97db97b 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -281,7 +281,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
{
struct vgcreate_params vp_new;
struct vgcreate_params vp_def;
- char *vg_name_from, *vg_name_to;
+ const char *vg_name_from, *vg_name_to;
struct volume_group *vg_to = NULL, *vg_from = NULL;
int opt;
int existing_vg = 0;