* [PATCH 00/20] Const fixes
@ 2010-12-16 10:36 Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 01/20] Add more strict const pointers around config tree Zdenek Kabelac
` (19 more replies)
0 siblings, 20 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Primary reason for this patchset is to make stronger
const limitation around config_tree handling.
So we can be sure where this tree could be modified.
It also cleanup quite a few hidden const warning
(-Wbad-function-cast -Wcast-qual)
Patch is extended with few more minor patches gathers
from my tree which should be easy to review. Some of them
are probably some minor bugs in the code so it's worth to
check them in.
Zdenek Kabelac (20):
Add more strict const pointers around config tree
Const fixes and additions
Use const char* const *
Remove wrong cast to (char*)
Remove const from destroy callback
Replace void* arithmetic with char*
Use const char * arithmetic for offset calculation
Use const char * for name and old_name in vg
Replace stack trace with failure exit path
Simplify usage fprintf clvmd
Add test for 'read' result
Add test for allocation results for node clonning
Properly use dm_free
Remove dead store in _clog_ctr
Remove dead assignment in _init_logging
Remove dead store in lvm_run_command
Remove dead assignment in dev_manager_transient
Remove dead assignment in _remove
Remove unused dev_dir_provided
Add internal error if pointer is uninitialized
daemons/clvmd/clvmd.c | 41 ++++++++--------
daemons/cmirrord/functions.c | 32 +++++-------
lib/activate/activate.c | 6 +-
lib/activate/dev_manager.c | 2 +-
lib/commands/toolcontext.c | 17 +++----
lib/config/config.c | 100 ++++++++++++++++++++++----------------
lib/config/config.h | 14 +++---
lib/datastruct/btree.c | 2 +-
lib/device/dev-cache.c | 6 +-
lib/error/errseg.c | 4 +-
lib/filters/filter-persistent.c | 2 +-
lib/filters/filter-regex.c | 8 ++--
lib/filters/filter-regex.h | 2 +-
lib/filters/filter.c | 4 +-
lib/format1/format1.c | 4 +-
lib/format_pool/disk_rep.c | 5 ++
lib/format_pool/format_pool.c | 6 +-
lib/format_text/flags.c | 2 +-
lib/format_text/format-text.c | 12 ++--
lib/format_text/import-export.h | 12 ++--
lib/format_text/import.c | 2 +-
lib/format_text/import_vsn1.c | 67 +++++++++++++-------------
lib/format_text/tags.c | 2 +-
lib/freeseg/freeseg.c | 4 +-
lib/metadata/lv_manip.c | 4 +-
lib/metadata/metadata.h | 4 +-
lib/metadata/segtype.h | 4 +-
lib/metadata/vg.h | 4 +-
lib/mirror/mirrored.c | 8 ++--
lib/mm/memlock.c | 2 +-
lib/replicator/replicator.c | 8 ++--
lib/snapshot/snapshot.c | 4 +-
lib/striped/striped.c | 6 +-
lib/unknown/unknown.c | 4 +-
lib/zero/zero.c | 4 +-
libdm/libdevmapper.h | 4 +-
libdm/regex/matcher.c | 2 +-
liblvm/lvm_base.c | 2 +-
tools/dmsetup.c | 10 ++--
tools/lvmcmdline.c | 20 +++++---
tools/toollib.c | 2 -
41 files changed, 232 insertions(+), 216 deletions(-)
--
1.7.3.3
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 01/20] Add more strict const pointers around config tree
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 02/20] Const fixes and additions Zdenek Kabelac
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
To have better control were config tree could be modified use more
const pointers and very carefully downcast them back to non-const.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/activate/activate.c | 4 +-
lib/commands/toolcontext.c | 14 ++++----
lib/config/config.c | 49 +++++++++++++++-------------
lib/config/config.h | 14 ++++----
lib/device/dev-cache.c | 2 +-
lib/filters/filter-persistent.c | 2 +-
lib/filters/filter-regex.c | 6 ++--
lib/filters/filter-regex.h | 2 +-
lib/filters/filter.c | 4 +-
lib/format_text/flags.c | 2 +-
lib/format_text/format-text.c | 8 ++--
lib/format_text/import-export.h | 12 +++---
lib/format_text/import_vsn1.c | 67 ++++++++++++++++++++-------------------
lib/format_text/tags.c | 2 +-
lib/metadata/lv_manip.c | 4 +-
lib/metadata/segtype.h | 2 +-
lib/mirror/mirrored.c | 4 +-
lib/mm/memlock.c | 2 +-
lib/replicator/replicator.c | 4 +-
lib/striped/striped.c | 2 +-
20 files changed, 105 insertions(+), 101 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 8f4953b..8e7a22f 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -260,8 +260,8 @@ static int _passes_activation_filter(struct cmd_context *cmd,
struct logical_volume *lv)
{
const struct config_node *cn;
- struct config_value *cv;
- char *str;
+ const struct config_value *cv;
+ const char *str;
char path[PATH_MAX];
if (!(cn = find_config_tree_node(cmd, "activation/volume_list"))) {
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c59238d..c5fc057 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -204,7 +204,7 @@ static int _process_config(struct cmd_context *cmd)
const char *read_ahead;
struct stat st;
const struct config_node *cn;
- struct config_value *cv;
+ const struct config_value *cv;
/* umask */
cmd->default_settings.umask = find_config_tree_int(cmd,
@@ -332,11 +332,11 @@ static int _set_tag(struct cmd_context *cmd, const char *tag)
return 1;
}
-static int _check_host_filters(struct cmd_context *cmd, struct config_node *hn,
+static int _check_host_filters(struct cmd_context *cmd, const struct config_node *hn,
int *passes)
{
- struct config_node *cn;
- struct config_value *cv;
+ const struct config_node *cn;
+ const struct config_value *cv;
*passes = 1;
@@ -561,7 +561,7 @@ static void _destroy_tag_configs(struct cmd_context *cmd)
static int _init_dev_cache(struct cmd_context *cmd)
{
const struct config_node *cn;
- struct config_value *cv;
+ const struct config_value *cv;
init_dev_disable_after_error_count(
find_config_tree_int(cmd, "devices/disable_after_error_count",
@@ -793,7 +793,7 @@ static int _init_formats(struct cmd_context *cmd)
if (!is_static() &&
(cn = find_config_tree_node(cmd, "global/format_libraries"))) {
- struct config_value *cv;
+ const struct config_value *cv;
struct format_type *(*init_format_fn) (struct cmd_context *);
void *lib;
@@ -959,7 +959,7 @@ static int _init_segtypes(struct cmd_context *cmd)
if (!is_static() &&
(cn = find_config_tree_node(cmd, "global/segment_libraries"))) {
- struct config_value *cv;
+ const struct config_value *cv;
int (*init_multiple_segtypes_fn) (struct cmd_context *,
struct segtype_library *);
diff --git a/lib/config/config.c b/lib/config/config.c
index 07c1f1c..6477877 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -420,7 +420,7 @@ static int _line_end(struct output_line *outline)
return 1;
}
-static int _write_value(struct output_line *outline, struct config_value *v)
+static int _write_value(struct output_line *outline, const struct config_value *v)
{
char *buf;
@@ -483,7 +483,7 @@ static int _write_config(const struct config_node *n, int only_one,
line_append("%s}", space);
} else {
/* it's a value */
- struct config_value *v = n->v;
+ const struct config_value *v = n->v;
line_append("=");
if (v->next) {
line_append("[");
@@ -526,7 +526,7 @@ int write_config_node(const struct config_node *cn, putline_fn putline, void *ba
int write_config_file(struct config_tree *cft, const char *file,
int argc, char **argv)
{
- struct config_node *cn;
+ const struct config_node *cn;
int r = 1;
struct output_line outline;
outline.fp = NULL;
@@ -669,6 +669,7 @@ static struct config_value *_type(struct parser *p)
{
/* [+-]{0,1}[0-9]+ | [0-9]*\.[0-9]* | ".*" */
struct config_value *v = _create_value(p->mem);
+ char *str;
if (!v)
return NULL;
@@ -700,9 +701,10 @@ static struct config_value *_type(struct parser *p)
v->type = CFG_STRING;
p->tb++, p->te--; /* strip "'s */
- if (!(v->v.str = _dup_tok(p)))
+ if (!(str = _dup_tok(p)))
return_0;
- unescape_double_quotes(v->v.str);
+ unescape_double_quotes(str);
+ v->v.str = str;
p->te++;
match(TOK_STRING_ESCAPED);
break;
@@ -894,8 +896,8 @@ static char *_dup_tok(struct parser *p)
/*
* utility functions
*/
-static struct config_node *_find_config_node(const struct config_node *cn,
- const char *path)
+static const struct config_node *_find_config_node(const struct config_node *cn,
+ const char *path)
{
const char *e;
const struct config_node *cn_found = NULL;
@@ -932,14 +934,14 @@ static struct config_node *_find_config_node(const struct config_node *cn,
path = e;
}
- return (struct config_node *) cn_found;
+ return cn_found;
}
-static struct config_node *_find_first_config_node(const struct config_node *cn1,
- const struct config_node *cn2,
- const char *path)
+static const struct config_node *_find_first_config_node(const struct config_node *cn1,
+ const struct config_node *cn2,
+ const char *path)
{
- struct config_node *cn;
+ const struct config_node *cn;
if (cn1 && (cn = _find_config_node(cn1, path)))
return cn;
@@ -950,8 +952,8 @@ static struct config_node *_find_first_config_node(const struct config_node *cn1
return NULL;
}
-struct config_node *find_config_node(const struct config_node *cn,
- const char *path)
+const struct config_node *find_config_node(const struct config_node *cn,
+ const char *path)
{
return _find_config_node(cn, path);
}
@@ -1026,7 +1028,7 @@ float find_config_float(const struct config_node *cn, const char *path,
return _find_config_float(cn, NULL, path, fail);
}
-struct config_node *find_config_tree_node(struct cmd_context *cmd,
+const struct config_node *find_config_tree_node(struct cmd_context *cmd,
const char *path)
{
return _find_first_config_node(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path);
@@ -1081,7 +1083,7 @@ static int _find_config_bool(const struct config_node *cn1,
const char *path, int fail)
{
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
- struct config_value *v;
+ const struct config_value *v;
if (!n)
return fail;
@@ -1138,7 +1140,7 @@ int get_config_uint64(const struct config_node *cn, const char *path,
}
int get_config_str(const struct config_node *cn, const char *path,
- char **result)
+ const char **result)
{
const struct config_node *n;
@@ -1185,7 +1187,7 @@ static void _merge_section(struct config_node *cn1, struct config_node *cn2)
/* Ignore - we don't have any of these yet */
continue;
/* Not already present? */
- if (!(oldn = find_config_node(cn1->child, cn->key))) {
+ if (!(oldn = (struct config_node*)find_config_node(cn1->child, cn->key))) {
_insert_config_node(&cn1->child, cn);
continue;
}
@@ -1205,9 +1207,9 @@ static void _merge_section(struct config_node *cn1, struct config_node *cn2)
}
}
-static int _match_host_tags(struct dm_list *tags, struct config_node *tn)
+static int _match_host_tags(struct dm_list *tags, const struct config_node *tn)
{
- struct config_value *tv;
+ const struct config_value *tv;
const char *str;
for (tv = tn->v; tv; tv = tv->next) {
@@ -1229,8 +1231,9 @@ static int _match_host_tags(struct dm_list *tags, struct config_node *tn)
int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft,
struct config_tree *newdata)
{
- struct config_node *root = cft->root;
- struct config_node *cn, *nextn, *oldn, *tn, *cn2;
+ const struct config_node *root = cft->root;
+ struct config_node *cn, *nextn, *oldn, *cn2;
+ const struct config_node *tn;
for (cn = newdata->root; cn; cn = nextn) {
nextn = cn->sib;
@@ -1242,7 +1245,7 @@ int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft,
if (!_match_host_tags(&cmd->tags, tn))
continue;
}
- if (!(oldn = find_config_node(root, cn->key))) {
+ if (!(oldn = (struct config_node *)find_config_node(root, cn->key))) {
_insert_config_node(&cft->root, cn);
/* Remove any "tags" nodes */
for (cn2 = cn->child; cn2; cn2 = cn2->sib) {
diff --git a/lib/config/config.h b/lib/config/config.h
index 2d16abd..f70deb0 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -33,13 +33,13 @@ struct config_value {
union {
int64_t i;
float r;
- char *str;
+ const char *str;
} v;
struct config_value *next; /* for arrays */
};
struct config_node {
- char *key;
+ const char *key;
struct config_node *parent, *sib, *child;
struct config_value *v;
};
@@ -78,8 +78,8 @@ int config_file_changed(struct config_tree *cft);
int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft,
struct config_tree *newdata);
-struct config_node *find_config_node(const struct config_node *cn,
- const char *path);
+const struct config_node *find_config_node(const struct config_node *cn,
+ const char *path);
const char *find_config_str(const struct config_node *cn, const char *path,
const char *fail);
int find_config_int(const struct config_node *cn, const char *path, int fail);
@@ -89,8 +89,8 @@ float find_config_float(const struct config_node *cn, const char *path,
/*
* These versions check an override tree, if present, first.
*/
-struct config_node *find_config_tree_node(struct cmd_context *cmd,
- const char *path);
+const struct config_node *find_config_tree_node(struct cmd_context *cmd,
+ const char *path);
const char *find_config_tree_str(struct cmd_context *cmd,
const char *path, const char *fail);
int find_config_tree_int(struct cmd_context *cmd, const char *path,
@@ -112,7 +112,7 @@ int get_config_uint64(const struct config_node *cn, const char *path,
uint64_t *result);
int get_config_str(const struct config_node *cn, const char *path,
- char **result);
+ const char **result);
unsigned maybe_config_section(const char *str, unsigned len);
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index ef93f4d..e4d0a76 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -541,7 +541,7 @@ void dev_cache_scan(int do_scan)
static int _init_preferred_names(struct cmd_context *cmd)
{
const struct config_node *cn;
- struct config_value *v;
+ const struct config_value *v;
struct dm_pool *scratch = NULL;
char **regex;
unsigned count = 0;
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 2ed9400..f3b1e05 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -68,7 +68,7 @@ static int _read_array(struct pfilter *pf, struct config_tree *cft,
const char *path, void *data)
{
const struct config_node *cn;
- struct config_value *cv;
+ const struct config_value *cv;
if (!(cn = find_config_node(cft->root, path))) {
log_very_verbose("Couldn't find %s array in '%s'",
diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c
index 7bc0a73..d7c079e 100644
--- a/lib/filters/filter-regex.c
+++ b/lib/filters/filter-regex.c
@@ -87,10 +87,10 @@ static int _extract_pattern(struct dm_pool *mem, const char *pat,
return 1;
}
-static int _build_matcher(struct rfilter *rf, struct config_value *val)
+static int _build_matcher(struct rfilter *rf, const struct config_value *val)
{
struct dm_pool *scratch;
- struct config_value *v;
+ const struct config_value *v;
char **regex;
unsigned count = 0;
int i, r = 0;
@@ -188,7 +188,7 @@ static void _regex_destroy(struct dev_filter *f)
dm_pool_destroy(rf->mem);
}
-struct dev_filter *regex_filter_create(struct config_value *patterns)
+struct dev_filter *regex_filter_create(const struct config_value *patterns)
{
struct dm_pool *mem = dm_pool_create("filter regex", 10 * 1024);
struct rfilter *rf;
diff --git a/lib/filters/filter-regex.h b/lib/filters/filter-regex.h
index 834145f..a009c91 100644
--- a/lib/filters/filter-regex.h
+++ b/lib/filters/filter-regex.h
@@ -27,6 +27,6 @@
* r|.*| - reject everything else
*/
-struct dev_filter *regex_filter_create(struct config_value *patterns);
+struct dev_filter *regex_filter_create(const struct config_value *patterns);
#endif
diff --git a/lib/filters/filter.c b/lib/filters/filter.c
index d570f79..c623d2a 100644
--- a/lib/filters/filter.c
+++ b/lib/filters/filter.c
@@ -185,8 +185,8 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
int line_maj = 0;
int blocksection = 0;
size_t dev_len = 0;
- struct config_value *cv;
- char *name;
+ const struct config_value *cv;
+ const char *name;
if (!*proc) {
diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c
index 994adf2..1d2a611 100644
--- a/lib/format_text/flags.c
+++ b/lib/format_text/flags.c
@@ -138,7 +138,7 @@ int print_flags(uint64_t status, int type, char *buffer, size_t size)
return 1;
}
-int read_flags(uint64_t *status, int type, struct config_value *cv)
+int read_flags(uint64_t *status, int type, const struct config_value *cv)
{
int f;
uint64_t s = UINT64_C(0);
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 4828e21..caab923 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2078,10 +2078,10 @@ static int _add_dir(const char *dir, struct dm_list *dir_list)
}
static int _get_config_disk_area(struct cmd_context *cmd,
- struct config_node *cn, struct dm_list *raw_list)
+ const struct config_node *cn, struct dm_list *raw_list)
{
struct device_area dev_area;
- char *id_str;
+ const char *id_str;
struct id id;
if (!(cn = cn->child)) {
@@ -2133,8 +2133,8 @@ static int _get_config_disk_area(struct cmd_context *cmd,
struct format_type *create_text_format(struct cmd_context *cmd)
{
struct format_type *fmt;
- struct config_node *cn;
- struct config_value *cv;
+ const struct config_node *cn;
+ const struct config_value *cv;
struct mda_lists *mda_lists;
if (!(fmt = dm_malloc(sizeof(*fmt))))
diff --git a/lib/format_text/import-export.h b/lib/format_text/import-export.h
index e59a3c2..3b56f08 100644
--- a/lib/format_text/import-export.h
+++ b/lib/format_text/import-export.h
@@ -44,14 +44,14 @@ enum {
};
struct text_vg_version_ops {
- int (*check_version) (struct config_tree * cf);
+ int (*check_version) (const struct config_tree * cf);
struct volume_group *(*read_vg) (struct format_instance * fid,
- struct config_tree * cf,
+ const struct config_tree *cf,
unsigned use_cached_pvs);
- void (*read_desc) (struct dm_pool * mem, struct config_tree * cf,
+ void (*read_desc) (struct dm_pool * mem, const struct config_tree *cf,
time_t *when, char **desc);
const char *(*read_vgname) (const struct format_type *fmt,
- struct config_tree *cft,
+ const struct config_tree *cft,
struct id *vgid, uint64_t *vgstatus,
char **creation_host);
};
@@ -59,10 +59,10 @@ struct text_vg_version_ops {
struct text_vg_version_ops *text_vg_vsn1_init(void);
int print_flags(uint64_t status, int type, char *buffer, size_t size);
-int read_flags(uint64_t *status, int type, struct config_value *cv);
+int read_flags(uint64_t *status, int type, const struct config_value *cv);
char *alloc_printed_tags(struct dm_list *tags);
-int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv);
+int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct config_value *cv);
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf);
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index afeb239..e5e83d4 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -26,8 +26,8 @@
#include "defaults.h"
typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem,
- struct volume_group * vg, struct config_node * pvn,
- struct config_node * vgn,
+ struct volume_group * vg, const struct config_node * pvn,
+ const struct config_node * vgn,
struct dm_hash_table * pv_hash,
struct dm_hash_table * lv_hash,
unsigned *scan_done_once,
@@ -54,10 +54,10 @@ static void _invalid_format(const char *str)
* Checks that the config file contains vg metadata, and that it
* we recognise the version number,
*/
-static int _check_version(struct config_tree *cft)
+static int _check_version(const struct config_tree *cft)
{
- struct config_node *cn;
- struct config_value *cv;
+ const struct config_node *cn;
+ const struct config_value *cv;
/*
* Check the contents field.
@@ -106,9 +106,9 @@ static int _is_converting(struct logical_volume *lv)
return 0;
}
-static int _read_id(struct id *id, struct config_node *cn, const char *path)
+static int _read_id(struct id *id, const struct config_node *cn, const char *path)
{
- struct config_value *cv;
+ const struct config_value *cv;
if (!(cn = find_config_node(cn, path))) {
log_error("Couldn't find uuid.");
@@ -129,9 +129,9 @@ static int _read_id(struct id *id, struct config_node *cn, const char *path)
return 1;
}
-static int _read_flag_config(struct config_node *n, uint64_t *status, int type)
+static int _read_flag_config(const struct config_node *n, uint64_t *status, int type)
{
- struct config_node *cn;
+ const struct config_node *cn;
*status = 0;
if (!(cn = find_config_node(n, "status"))) {
@@ -155,8 +155,8 @@ static int _read_flag_config(struct config_node *n, uint64_t *status, int type)
}
static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
- struct volume_group *vg, struct config_node *pvn,
- struct config_node *vgn __attribute__((unused)),
+ struct volume_group *vg, const struct config_node *pvn,
+ const struct config_node *vgn __attribute__((unused)),
struct dm_hash_table *pv_hash,
struct dm_hash_table *lv_hash __attribute__((unused)),
unsigned *scan_done_once,
@@ -164,7 +164,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
{
struct physical_volume *pv;
struct pv_list *pvl;
- struct config_node *cn;
+ const struct config_node *cn;
uint64_t size;
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
@@ -293,13 +293,13 @@ static void _insert_segment(struct logical_volume *lv, struct lv_segment *seg)
}
static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
- struct logical_volume *lv, struct config_node *sn,
+ struct logical_volume *lv, const struct config_node *sn,
struct dm_hash_table *pv_hash)
{
uint32_t area_count = 0u;
struct lv_segment *seg;
- struct config_node *cn, *sn_child = sn->child;
- struct config_value *cv;
+ const struct config_node *cn, *sn_child = sn->child;
+ const struct config_value *cv;
uint32_t start_extent, extent_count;
struct segment_type *segtype;
const char *segtype_str;
@@ -380,7 +380,7 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
uint64_t status)
{
unsigned int s;
- struct config_value *cv;
+ const struct config_value *cv;
struct logical_volume *lv1;
struct physical_volume *pv;
const char *seg_name = config_parent_name(sn);
@@ -440,10 +440,10 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
}
static int _read_segments(struct dm_pool *mem, struct volume_group *vg,
- struct logical_volume *lv, struct config_node *lvn,
+ struct logical_volume *lv, const struct config_node *lvn,
struct dm_hash_table *pv_hash)
{
- struct config_node *sn;
+ const struct config_node *sn;
int count = 0, seg_count;
for (sn = lvn; sn; sn = sn->sib) {
@@ -493,15 +493,15 @@ static int _read_segments(struct dm_pool *mem, struct volume_group *vg,
static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
struct dm_pool *mem,
- struct volume_group *vg, struct config_node *lvn,
- struct config_node *vgn __attribute__((unused)),
+ struct volume_group *vg, const struct config_node *lvn,
+ const struct config_node *vgn __attribute__((unused)),
struct dm_hash_table *pv_hash __attribute__((unused)),
struct dm_hash_table *lv_hash,
unsigned *scan_done_once __attribute__((unused)),
unsigned report_missing_devices __attribute__((unused)))
{
struct logical_volume *lv;
- struct config_node *cn;
+ const struct config_node *cn;
if (!(lv = alloc_lv(mem)))
return_0;
@@ -522,7 +522,7 @@ static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
lv->alloc = ALLOC_INHERIT;
if ((cn = find_config_node(lvn, "allocation_policy"))) {
- struct config_value *cv = cn->v;
+ const struct config_value *cv = cn->v;
if (!cv || !cv->v.str) {
log_error("allocation_policy must be a string.");
return 0;
@@ -567,8 +567,8 @@ static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
static int _read_lvsegs(struct format_instance *fid __attribute__((unused)),
struct dm_pool *mem,
- struct volume_group *vg, struct config_node *lvn,
- struct config_node *vgn __attribute__((unused)),
+ struct volume_group *vg, const struct config_node *lvn,
+ const struct config_node *vgn __attribute__((unused)),
struct dm_hash_table *pv_hash,
struct dm_hash_table *lv_hash,
unsigned *scan_done_once __attribute__((unused)),
@@ -621,13 +621,13 @@ static int _read_lvsegs(struct format_instance *fid __attribute__((unused)),
static int _read_sections(struct format_instance *fid,
const char *section, section_fn fn,
struct dm_pool *mem,
- struct volume_group *vg, struct config_node *vgn,
+ struct volume_group *vg, const struct config_node *vgn,
struct dm_hash_table *pv_hash,
struct dm_hash_table *lv_hash,
int optional,
unsigned *scan_done_once)
{
- struct config_node *n;
+ const struct config_node *n;
/* Only report missing devices when doing a scan */
unsigned report_missing_devices = scan_done_once ? !*scan_done_once : 1;
@@ -641,7 +641,8 @@ static int _read_sections(struct format_instance *fid,
}
for (n = n->child; n; n = n->sib) {
- if (!fn(fid, mem, vg, n, vgn, pv_hash, lv_hash, scan_done_once, report_missing_devices))
+ if (!fn(fid, mem, vg, n, vgn, pv_hash, lv_hash,
+ scan_done_once, report_missing_devices))
return_0;
}
@@ -649,10 +650,10 @@ static int _read_sections(struct format_instance *fid,
}
static struct volume_group *_read_vg(struct format_instance *fid,
- struct config_tree *cft,
+ const struct config_tree *cft,
unsigned use_cached_pvs)
{
- struct config_node *vgn, *cn;
+ const struct config_node *vgn, *cn;
struct volume_group *vg;
struct dm_hash_table *pv_hash = NULL, *lv_hash = NULL;
struct dm_pool *mem = dm_pool_create("lvm2 vg_read", VG_MEMPOOL_CHUNK);
@@ -738,7 +739,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
vg->alloc = ALLOC_NORMAL;
if ((cn = find_config_node(vgn, "allocation_policy"))) {
- struct config_value *cv = cn->v;
+ const struct config_value *cv = cn->v;
if (!cv || !cv->v.str) {
log_error("allocation_policy must be a string.");
goto bad;
@@ -832,7 +833,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
}
static void _read_desc(struct dm_pool *mem,
- struct config_tree *cft, time_t *when, char **desc)
+ const struct config_tree *cft, time_t *when, char **desc)
{
const char *d;
unsigned int u = 0u;
@@ -848,10 +849,10 @@ static void _read_desc(struct dm_pool *mem,
}
static const char *_read_vgname(const struct format_type *fmt,
- struct config_tree *cft, struct id *vgid,
+ const struct config_tree *cft, struct id *vgid,
uint64_t *vgstatus, char **creation_host)
{
- struct config_node *vgn;
+ const struct config_node *vgn;
struct dm_pool *mem = fmt->cmd->mem;
char *vgname;
int old_suppress;
diff --git a/lib/format_text/tags.c b/lib/format_text/tags.c
index 1a8c254..76d42db 100644
--- a/lib/format_text/tags.c
+++ b/lib/format_text/tags.c
@@ -61,7 +61,7 @@ bad:
return_NULL;
}
-int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv)
+int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct config_value *cv)
{
if (cv->type == CFG_EMPTY_ARRAY)
return 1;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 0de4ec3..7ecddb4 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -958,8 +958,8 @@ static int _is_same_pv(struct pv_match *pvmatch __attribute((unused)), struct pv
*/
static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvseg, struct pv_area *pva)
{
- struct config_value *cv;
- char *str;
+ const struct config_value *cv;
+ const char *str;
const char *tag_matched;
for (cv = pvmatch->cling_tag_list_cn->v; cv; cv = cv->next) {
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 6ac2f96..8bf16d7 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -70,7 +70,7 @@ struct segtype_handler {
void (*display) (const struct lv_segment * seg);
int (*text_export) (const struct lv_segment * seg,
struct formatter * f);
- int (*text_import_area_count) (struct config_node * sn,
+ int (*text_import_area_count) (const struct config_node * sn,
uint32_t *area_count);
int (*text_import) (struct lv_segment * seg,
const struct config_node * sn,
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index dbb6fc7..a02ccb5 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -72,7 +72,7 @@ static void _mirrored_display(const struct lv_segment *seg)
log_print(" ");
}
-static int _mirrored_text_import_area_count(struct config_node *sn, uint32_t *area_count)
+static int _mirrored_text_import_area_count(const struct config_node *sn, uint32_t *area_count)
{
if (!get_config_uint32(sn, "mirror_count", area_count)) {
log_error("Couldn't read 'mirror_count' for "
@@ -87,7 +87,7 @@ static int _mirrored_text_import(struct lv_segment *seg, const struct config_nod
struct dm_hash_table *pv_hash)
{
const struct config_node *cn;
- char *logname = NULL;
+ const char *logname = NULL;
if (find_config_node(sn, "extents_moved")) {
if (get_config_uint32(sn, "extents_moved",
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 1e3065c..062b765 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -124,7 +124,7 @@ static void _release_memory(void)
static int _maps_line(const struct config_node *cn, lvmlock_t lock,
const char* line, size_t* mstats)
{
- struct config_value *cv;
+ const struct config_value *cv;
long from, to;
int pos, i;
char fr, fw, fx, fp;
diff --git a/lib/replicator/replicator.c b/lib/replicator/replicator.c
index 1036c0d..1753bca 100644
--- a/lib/replicator/replicator.c
+++ b/lib/replicator/replicator.c
@@ -89,7 +89,7 @@ static const char _state_txt[NUM_REPLICATOR_STATE][8] = {
static replicator_state_t _get_state(const struct config_node *sn,
const char *path, replicator_state_t def)
{
- char *str;
+ const char *str;
unsigned i;
if (get_config_str(sn, path, &str)) {
@@ -118,7 +118,7 @@ static const char _op_mode_txt[NUM_DM_REPLICATOR_MODES][8] = {
static dm_replicator_mode_t _get_op_mode(const struct config_node *sn,
const char *path, dm_replicator_mode_t def)
{
- char *str;
+ const char *str;
unsigned i;
if (get_config_str(sn, path, &str)) {
diff --git a/lib/striped/striped.c b/lib/striped/striped.c
index 44f9774..7ba963b 100644
--- a/lib/striped/striped.c
+++ b/lib/striped/striped.c
@@ -57,7 +57,7 @@ static void _striped_display(const struct lv_segment *seg)
log_print(" ");
}
-static int _striped_text_import_area_count(struct config_node *sn, uint32_t *area_count)
+static int _striped_text_import_area_count(const struct config_node *sn, uint32_t *area_count)
{
if (!get_config_uint32(sn, "stripe_count", area_count)) {
log_error("Couldn't read 'stripe_count' for "
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 02/20] Const fixes and additions
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 01/20] Add more strict const pointers around config tree Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 03/20] Use const char* const * Zdenek Kabelac
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/config/config.c | 4 ++--
lib/datastruct/btree.c | 2 +-
lib/format_pool/format_pool.c | 2 +-
lib/format_text/import.c | 2 +-
lib/metadata/metadata.h | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 6477877..1df8d09 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -239,8 +239,8 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
}
if (checksum_fn && checksum !=
- (checksum_fn(checksum_fn(INITIAL_CRC, (uint8_t *)p->fb, size),
- (uint8_t *)(p->fb + size), size2))) {
+ (checksum_fn(checksum_fn(INITIAL_CRC, (const uint8_t *)p->fb, size),
+ (const uint8_t *)(p->fb + size), size2))) {
log_error("%s: Checksum error", dev_name(dev));
goto out;
}
diff --git a/lib/datastruct/btree.c b/lib/datastruct/btree.c
index 9446008..bfcdca6 100644
--- a/lib/datastruct/btree.c
+++ b/lib/datastruct/btree.c
@@ -103,7 +103,7 @@ int btree_insert(struct btree *t, uint32_t k, void *data)
void *btree_get_data(const struct btree_iter *it)
{
- return ((struct node *) it)->data;
+ return ((const struct node *) it)->data;
}
static struct node *_left(struct node *n)
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index 04b5611..545195b 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -75,7 +75,7 @@ static struct user_subpool *_build_usp(struct dm_list *pls, struct dm_pool *mem,
return usp;
}
-static int _check_usp(char *vgname, struct user_subpool *usp, int sp_count)
+static int _check_usp(const char *vgname, struct user_subpool *usp, int sp_count)
{
int i;
unsigned j;
diff --git a/lib/format_text/import.c b/lib/format_text/import.c
index 3e0df94..60f465f 100644
--- a/lib/format_text/import.c
+++ b/lib/format_text/import.c
@@ -131,7 +131,7 @@ struct volume_group *text_vg_import_file(struct format_instance *fid,
when, desc);
}
-struct volume_group *import_vg_from_buffer(char *buf,
+struct volume_group *import_vg_from_buffer(const char *buf,
struct format_instance *fid)
{
struct volume_group *vg = NULL;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 6ed467e..815e460 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -386,7 +386,7 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea
* For internal metadata caching.
*/
int export_vg_to_buffer(struct volume_group *vg, char **buf);
-struct volume_group *import_vg_from_buffer(char *buf,
+struct volume_group *import_vg_from_buffer(const char *buf,
struct format_instance *fid);
/*
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 03/20] Use const char* const *
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 01/20] Add more strict const pointers around config tree Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 02/20] Const fixes and additions Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 04/20] Remove wrong cast to (char*) Zdenek Kabelac
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Fix const warning for casting char** to const char*.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/device/dev-cache.c | 4 ++--
libdm/libdevmapper.h | 2 +-
libdm/regex/matcher.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index e4d0a76..962aa1e 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -543,7 +543,7 @@ static int _init_preferred_names(struct cmd_context *cmd)
const struct config_node *cn;
const struct config_value *v;
struct dm_pool *scratch = NULL;
- char **regex;
+ const char **regex;
unsigned count = 0;
int i, r = 0;
@@ -583,7 +583,7 @@ static int _init_preferred_names(struct cmd_context *cmd)
}
if (!(_cache.preferred_names_matcher =
- dm_regex_create(_cache.mem,(const char **) regex, count))) {
+ dm_regex_create(_cache.mem, regex, count))) {
log_error("Preferred device name pattern matcher creation failed.");
goto out;
}
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 3083f9a..d385030 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1020,7 +1020,7 @@ struct dm_regex;
* Initialise an array of num patterns for matching.
* Uses memory from mem.
*/
-struct dm_regex *dm_regex_create(struct dm_pool *mem, const char **patterns,
+struct dm_regex *dm_regex_create(struct dm_pool *mem, const char * const *patterns,
unsigned num_patterns);
/*
diff --git a/libdm/regex/matcher.c b/libdm/regex/matcher.c
index eb20bd0..9590865 100644
--- a/libdm/regex/matcher.c
+++ b/libdm/regex/matcher.c
@@ -310,7 +310,7 @@ static void _force_states(struct dm_regex *m)
}
}
-struct dm_regex *dm_regex_create(struct dm_pool *mem, const char **patterns,
+struct dm_regex *dm_regex_create(struct dm_pool *mem, const char * const *patterns,
unsigned num_patterns)
{
char *all, *ptr;
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 04/20] Remove wrong cast to (char*)
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (2 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 03/20] Use const char* const * Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 05/20] Remove const from destroy callback Zdenek Kabelac
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
liblvm/lvm_base.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/liblvm/lvm_base.c b/liblvm/lvm_base.c
index f8e1004..9e1a8ec 100644
--- a/liblvm/lvm_base.c
+++ b/liblvm/lvm_base.c
@@ -61,7 +61,7 @@ lvm_t lvm_init(const char *system_dir)
* archive() call. Possible example:
* cmd_line = "lvm_vg_create: vg1\nlvm_vg_extend vg1 /dev/sda1\n"
*/
- cmd->cmd_line = (char *)"liblvm";
+ cmd->cmd_line = "liblvm";
return (lvm_t) cmd;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 05/20] Remove const from destroy callback
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (3 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 04/20] Remove wrong cast to (char*) Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 06/20] Replace void* arithmetic with char* Zdenek Kabelac
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
We have 2 choices here:
- add dm_free_c(const void*) to accept const pointers for free
and make just one const void* -> void* cast there.
- stick with 'standard' way of freeing non-const pointers - i.e
when freeing point we usually have the writable structure.
So this patch removes 'const' from destroy() function callbacks.
Note: i.e. in _text_destroy() we even operate on passed const pointer.
2nd note we still have functions which need to free static pointers,
so this patch doesn't fix all places - but it's get down to very few
occurences.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/error/errseg.c | 4 ++--
lib/format1/format1.c | 4 ++--
lib/format_pool/format_pool.c | 4 ++--
lib/format_text/format-text.c | 4 ++--
lib/freeseg/freeseg.c | 4 ++--
lib/metadata/metadata.h | 2 +-
lib/metadata/segtype.h | 2 +-
lib/mirror/mirrored.c | 4 ++--
lib/replicator/replicator.c | 4 ++--
lib/snapshot/snapshot.c | 4 ++--
lib/striped/striped.c | 4 ++--
lib/unknown/unknown.c | 4 ++--
lib/zero/zero.c | 4 ++--
13 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/lib/error/errseg.c b/lib/error/errseg.c
index 6cfcd79..add1df8 100644
--- a/lib/error/errseg.c
+++ b/lib/error/errseg.c
@@ -81,9 +81,9 @@ static int _errseg_modules_needed(struct dm_pool *mem,
return 1;
}
-static void _errseg_destroy(const struct segment_type *segtype)
+static void _errseg_destroy(struct segment_type *segtype)
{
- dm_free((void *)segtype);
+ dm_free(segtype);
}
static struct segtype_handler _error_ops = {
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 0dcec05..b35bd98 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -555,9 +555,9 @@ static void _format1_destroy_instance(struct format_instance *fid __attribute__(
{
}
-static void _format1_destroy(const struct format_type *fmt)
+static void _format1_destroy(struct format_type *fmt)
{
- dm_free((void *) fmt);
+ dm_free(fmt);
}
static struct format_handler _format1_ops = {
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index 545195b..730da87 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -286,9 +286,9 @@ static void _pool_destroy_instance(struct format_instance *fid __attribute__((un
{
}
-static void _pool_destroy(const struct format_type *fmt)
+static void _pool_destroy(struct format_type *fmt)
{
- dm_free((void *) fmt);
+ dm_free(fmt);
}
/* *INDENT-OFF* */
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index caab923..c186757 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1719,7 +1719,7 @@ static void _free_raws(struct dm_list *raw_list)
}
}
-static void _text_destroy(const struct format_type *fmt)
+static void _text_destroy(struct format_type *fmt)
{
if (fmt->private) {
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
@@ -1727,7 +1727,7 @@ static void _text_destroy(const struct format_type *fmt)
dm_free(fmt->private);
}
- dm_free((void *)fmt);
+ dm_free(fmt);
}
static struct metadata_area_ops _metadata_text_file_ops = {
diff --git a/lib/freeseg/freeseg.c b/lib/freeseg/freeseg.c
index 08f3100..8e73be0 100644
--- a/lib/freeseg/freeseg.c
+++ b/lib/freeseg/freeseg.c
@@ -31,9 +31,9 @@ static const char *_freeseg_name(const struct lv_segment *seg)
return seg->segtype->name;
}
-static void _freeseg_destroy(const struct segment_type *segtype)
+static void _freeseg_destroy(struct segment_type *segtype)
{
- dm_free((void *)segtype);
+ dm_free(segtype);
}
static struct segtype_handler _freeseg_ops = {
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 815e460..08bff4a 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -291,7 +291,7 @@ struct format_handler {
/*
* Destructor for format type
*/
- void (*destroy) (const struct format_type * fmt);
+ void (*destroy) (struct format_type * fmt);
};
/*
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 8bf16d7..6d50746 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -97,7 +97,7 @@ struct segtype_handler {
int (*modules_needed) (struct dm_pool *mem,
const struct lv_segment *seg,
struct dm_list *modules);
- void (*destroy) (const struct segment_type * segtype);
+ void (*destroy) (struct segment_type * segtype);
int (*target_monitored) (struct lv_segment *seg, int *pending);
int (*target_monitor_events) (struct lv_segment *seg, int events);
int (*target_unmonitor_events) (struct lv_segment *seg, int events);
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index a02ccb5..3d25d70 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -600,9 +600,9 @@ static int _mirrored_modules_needed(struct dm_pool *mem,
return 1;
}
-static void _mirrored_destroy(const struct segment_type *segtype)
+static void _mirrored_destroy(struct segment_type *segtype)
{
- dm_free((void *) segtype);
+ dm_free(segtype);
}
static struct segtype_handler _mirrored_ops = {
diff --git a/lib/replicator/replicator.c b/lib/replicator/replicator.c
index 1753bca..26a5cf1 100644
--- a/lib/replicator/replicator.c
+++ b/lib/replicator/replicator.c
@@ -406,9 +406,9 @@ static int _replicator_modules_needed(struct dm_pool *mem,
return 1;
}
-static void _replicator_destroy(const struct segment_type *segtype)
+static void _replicator_destroy(struct segment_type *segtype)
{
- dm_free((void *)segtype);
+ dm_free(segtype);
}
static struct segtype_handler _replicator_ops = {
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index e1612f9..1a98d7e 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -218,9 +218,9 @@ static int _snap_modules_needed(struct dm_pool *mem,
return 1;
}
-static void _snap_destroy(const struct segment_type *segtype)
+static void _snap_destroy(struct segment_type *segtype)
{
- dm_free((void *)segtype);
+ dm_free(segtype);
}
static struct segtype_handler _snapshot_ops = {
diff --git a/lib/striped/striped.c b/lib/striped/striped.c
index 7ba963b..51bf24a 100644
--- a/lib/striped/striped.c
+++ b/lib/striped/striped.c
@@ -199,9 +199,9 @@ static int _striped_target_present(struct cmd_context *cmd,
}
#endif
-static void _striped_destroy(const struct segment_type *segtype)
+static void _striped_destroy(struct segment_type *segtype)
{
- dm_free((void *)segtype);
+ dm_free(segtype);
}
static struct segtype_handler _striped_ops = {
diff --git a/lib/unknown/unknown.c b/lib/unknown/unknown.c
index 6dc00f6..332ae99 100644
--- a/lib/unknown/unknown.c
+++ b/lib/unknown/unknown.c
@@ -74,9 +74,9 @@ static int _unknown_add_target_line(struct dev_manager *dm __attribute__((unused
}
#endif
-static void _unknown_destroy(const struct segment_type *segtype)
+static void _unknown_destroy(struct segment_type *segtype)
{
- dm_free((void *)segtype);
+ dm_free(segtype);
}
static struct segtype_handler _unknown_ops = {
diff --git a/lib/zero/zero.c b/lib/zero/zero.c
index 7e5ffa6..16ce66c 100644
--- a/lib/zero/zero.c
+++ b/lib/zero/zero.c
@@ -78,9 +78,9 @@ static int _zero_modules_needed(struct dm_pool *mem,
return 1;
}
-static void _zero_destroy(const struct segment_type *segtype)
+static void _zero_destroy(struct segment_type *segtype)
{
- dm_free((void *) segtype);
+ dm_free(segtype);
}
static struct segtype_handler _zero_ops = {
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 06/20] Replace void* arithmetic with char*
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (4 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 05/20] Remove const from destroy callback Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 07/20] Use const char * arithmetic for offset calculation Zdenek Kabelac
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/activate/activate.c | 2 +-
tools/dmsetup.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 8e7a22f..5510977 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -399,7 +399,7 @@ int target_version(const char *target_name, uint32_t *maj,
goto out;
}
- target = (void *) target + target->next;
+ target = (struct dm_versions *)((char *) target + target->next);
} while (last_target != target);
out:
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 1a56d24..56f1579 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -1288,8 +1288,8 @@ static int _process_all(int argc, char **argv, int silent,
}
do {
- names = (void *) names + next;
- if (!fn(argc, argv, (void *) names))
+ names = (struct dm_names *)((char *) names + next);
+ if (!fn(argc, argv, names))
r = 0;
next = names->next;
} while (next);
@@ -1632,7 +1632,7 @@ static int _targets(int argc __attribute__((unused)), char **argv __attribute__(
printf("%-16s v%d.%d.%d\n", target->name, target->version[0],
target->version[1], target->version[2]);
- target = (void *) target + target->next;
+ target = (struct dm_versions *)((char *) target + target->next);
} while (last_target != target);
r = 1;
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 07/20] Use const char * arithmetic for offset calculation
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (5 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 06/20] Replace void* arithmetic with char* Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 08/20] Use const char * for name and old_name in vg Zdenek Kabelac
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
As 'const' types are also passed to this macro - lets keep
offset calculation with const char *. Cleans several gcc
constness warnings.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
libdm/libdevmapper.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index d385030..4aa9991 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -814,7 +814,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
* contained in a structure of type t, return the containing structure.
*/
#define dm_list_struct_base(v, t, head) \
- ((t *)((char*)(v) - (char*)&((t *) 0)->head))
+ ((t *)((const char *)(v) - (const char *)&((t *) 0)->head))
/*
* Given the address v of an instance of 'struct dm_list list' contained in
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 08/20] Use const char * for name and old_name in vg
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (6 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 07/20] Use const char * arithmetic for offset calculation Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 09/20] Replace stack trace with failure exit path Zdenek Kabelac
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Turn pointers to const char - to avoid changes of these struct
members. (Having better control over, were the members could
be modified).
Idea for future: system_id should be probably char[NAME_LEN]
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/metadata/vg.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index eb9debc..448dcfe 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -43,8 +43,8 @@ struct volume_group {
uint64_t status;
struct id id;
- char *name;
- char *old_name; /* Set during vgrename and vgcfgrestore */
+ const char *name;
+ const char *old_name; /* Set during vgrename and vgcfgrestore */
char *system_id;
uint32_t extent_size;
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 09/20] Replace stack trace with failure exit path
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (7 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 08/20] Use const char * for name and old_name in vg Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 10/20] Simplify usage fprintf clvmd Zdenek Kabelac
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
WARNING: functional change!
It looks like bug - an error return should be here
- but the code currently ignores fail in engine construction
- is there any use of rfilter without engine ?
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/filters/filter-regex.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c
index d7c079e..e046c71 100644
--- a/lib/filters/filter-regex.c
+++ b/lib/filters/filter-regex.c
@@ -137,7 +137,7 @@ static int _build_matcher(struct rfilter *rf, const struct config_value *val)
*/
if (!(rf->engine = dm_regex_create(rf->mem, (const char **) regex,
count)))
- stack;
+ goto_out;
r = 1;
out:
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 10/20] Simplify usage fprintf clvmd
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (8 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 09/20] Replace stack trace with failure exit path Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 11/20] Add test for 'read' result Zdenek Kabelac
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Use one fprintf for usage print.
Use const char* for prog parameter.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
daemons/clvmd/clvmd.c | 41 ++++++++++++++++++++---------------------
1 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 45e2486..1a35c49 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -143,38 +143,37 @@ static void add_reply_to_list(struct local_client *client, int status,
static if_type_t parse_cluster_interface(char *ifname);
static if_type_t get_cluster_type(void);
-static void usage(char *prog, FILE *file)
+static void usage(const char *prog, FILE *file)
{
- fprintf(file, "Usage:\n");
- fprintf(file, "%s [Vhd]\n", prog);
- fprintf(file, "\n");
- fprintf(file, " -V Show version of clvmd\n");
- fprintf(file, " -h Show this help information\n");
- fprintf(file, " -d Set debug level\n");
- fprintf(file, " If starting clvmd then don't fork, run in the foreground\n");
- fprintf(file, " -R Tell all running clvmds in the cluster to reload their device cache\n");
- fprintf(file, " -S Restart clvmd, preserving exclusive locks\n");
- fprintf(file, " -C Sets debug level (from -d) on all clvmd instances clusterwide\n");
- fprintf(file, " -t<secs> Command timeout (default 60 seconds)\n");
- fprintf(file, " -T<secs> Startup timeout (default none)\n");
- fprintf(file, " -I<cmgr> Cluster manager (default: auto)\n");
- fprintf(file, " Available cluster managers: ");
+ fprintf(file, "Usage:\n"
+ "%s [Vhd]\n\n"
+ " -V Show version of clvmd\n"
+ " -h Show this help information\n"
+ " -d Set debug level\n"
+ " If starting clvmd then don't fork, run in the foreground\n"
+ " -R Tell all running clvmds in the cluster to reload their device cache\n"
+ " -S Restart clvmd, preserving exclusive locks\n"
+ " -C Sets debug level (from -d) on all clvmd instances clusterwide\n"
+ " -t<secs> Command timeout (default 60 seconds)\n"
+ " -T<secs> Startup timeout (default none)\n"
+ " -I<cmgr> Cluster manager (default: auto)\n"
+ " Available cluster managers: "
#ifdef USE_COROSYNC
- fprintf(file, "corosync ");
+ "corosync "
#endif
#ifdef USE_CMAN
- fprintf(file, "cman ");
+ "cman "
#endif
#ifdef USE_OPENAIS
- fprintf(file, "openais ");
+ "openais "
#endif
#ifdef USE_GULM
- fprintf(file, "gulm ");
+ "gulm "
#endif
#ifdef USE_SINGLENODE
- fprintf(file, "singlenode");
+ "singlenode "
#endif
- fprintf(file, "\n");
+ "\n", prog);
}
/* Called to signal the parent how well we got on during initialisation */
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 11/20] Add test for 'read' result
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (9 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 10/20] Simplify usage fprintf clvmd Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 12/20] Add test for allocation results for node clonning Zdenek Kabelac
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Read result should not be ignored.
Add some small check even when there is very low probability to
fail in this place.
FIXME Generic read routine should be used.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
tools/lvmcmdline.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 9f20d4b..dcb1f28 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1191,15 +1191,19 @@ static const char *_get_cmdline(pid_t pid)
{
static char _proc_cmdline[32];
char buf[256];
- int fd;
+ int fd, n = 0;
snprintf(buf, sizeof(buf), DEFAULT_PROC_DIR "/%u/cmdline", pid);
+ /* FIXME Use generic read code. */
if ((fd = open(buf, O_RDONLY)) > 0) {
- read(fd, _proc_cmdline, sizeof(_proc_cmdline) - 1);
- _proc_cmdline[sizeof(_proc_cmdline) - 1] = '\0';
- close(fd);
- } else
- _proc_cmdline[0] = '\0';
+ if ((n = read(fd, _proc_cmdline, sizeof(_proc_cmdline) - 1)) < 0) {
+ log_sys_error("read", buf);
+ n = 0;
+ }
+ if (close(fd))
+ log_sys_error("close", buf);
+ }
+ _proc_cmdline[n] = '\0';
return _proc_cmdline;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 12/20] Add test for allocation results for node clonning
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (10 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 11/20] Add test for 'read' result Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 13/20] Properly use dm_free Zdenek Kabelac
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Add checks for clonning allocation a fail-out when something is
not allocated correctly.
Also move var declaration at begining of function.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/config/config.c | 47 ++++++++++++++++++++++++++++++-----------------
1 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 1df8d09..56216a2 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1330,30 +1330,43 @@ unsigned maybe_config_section(const char *str, unsigned len)
static struct config_value *_clone_config_value(struct dm_pool *mem, const struct config_value *v)
{
+ struct config_value *new_cv;
+
if (!v)
return NULL;
- struct config_value *new = _create_value(mem);
- new->type = v->type;
- if (v->type == CFG_STRING)
- new->v.str = dm_pool_strdup(mem, v->v.str);
- else
- new->v = v->v;
- new->next = _clone_config_value(mem, v->next);
- return new;
+
+ if (!(new_cv = _create_value(mem)))
+ return_NULL;
+
+ new_cv->type = v->type;
+ if (v->type == CFG_STRING) {
+ if (!(new_cv->v.str = dm_pool_strdup(mem, v->v.str)))
+ return_NULL;
+ } else
+ new_cv->v = v->v;
+
+ if (v->next && !(new_cv->next = _clone_config_value(mem, v->next)))
+ return_NULL;
+
+ return new_cv;
}
struct config_node *clone_config_node(struct dm_pool *mem, const struct config_node *cn,
int siblings)
{
+ struct config_node *new_cn;
+
if (!cn)
return NULL;
- struct config_node *new = _create_node(mem);
- new->key = dm_pool_strdup(mem, cn->key);
- new->child = clone_config_node(mem, cn->child, 1);
- new->v = _clone_config_value(mem, cn->v);
- if (siblings)
- new->sib = clone_config_node(mem, cn->sib, siblings);
- else
- new->sib = NULL;
- return new;
+
+ if (!(new_cn = _create_node(mem)))
+ return_NULL;
+
+ if ((cn->key && !(new_cn->key = dm_pool_strdup(mem, cn->key))) ||
+ (cn->child && !(new_cn->child = clone_config_node(mem, cn->child, 1))) ||
+ (cn->v && !(new_cn->v = _clone_config_value(mem, cn->v))) ||
+ (siblings && cn->sib && !(new_cn->sib = clone_config_node(mem, cn->sib, siblings))))
+ return_NULL; /* 'new_cn' released with mem pool */
+
+ return new_cn;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 13/20] Properly use dm_free
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (11 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 12/20] Add test for allocation results for node clonning Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 14/20] Remove dead store in _clog_ctr Zdenek Kabelac
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Use dm_zalloc to obtain zeroed memory block.
Use dm_free for dm_ allocated memory blocks.
Test close() for error.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
daemons/cmirrord/functions.c | 27 ++++++++++++---------------
1 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index 58e76ac..d773c42 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -429,13 +429,12 @@ static int _clog_ctr(char *uuid, uint64_t luid,
block_on_error = 1;
}
- lc = malloc(sizeof(*lc));
+ lc = dm_zalloc(sizeof(*lc));
if (!lc) {
LOG_ERROR("Unable to allocate cluster log context");
r = -ENOMEM;
goto fail;
}
- memset(lc, 0, sizeof(*lc));
lc->region_size = region_size;
lc->region_count = region_count;
@@ -453,7 +452,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
(duplicate = get_pending_log(lc->uuid, lc->luid))) {
LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
SHORT_UUID(lc->uuid), lc->luid);
- free(lc);
+ dm_free(lc);
return -EINVAL;
}
@@ -511,15 +510,13 @@ static int _clog_ctr(char *uuid, uint64_t luid,
return 0;
fail:
if (lc) {
- if (lc->clean_bits)
- free(lc->clean_bits);
- if (lc->sync_bits)
- free(lc->sync_bits);
- if (lc->disk_buffer)
- free(lc->disk_buffer);
- if (lc->disk_fd >= 0)
- close(lc->disk_fd);
- free(lc);
+ if (lc->disk_fd >= 0 && close(lc->disk_fd))
+ LOG_ERROR("Close device error, %s: %s",
+ disk_path, strerror(errno));
+ free(lc->disk_buffer);
+ dm_free(lc->sync_bits);
+ dm_free(lc->clean_bits);
+ dm_free(lc);
}
return r;
}
@@ -634,9 +631,9 @@ static int clog_dtr(struct dm_ulog_request *rq)
close(lc->disk_fd);
if (lc->disk_buffer)
free(lc->disk_buffer);
- free(lc->clean_bits);
- free(lc->sync_bits);
- free(lc);
+ dm_free(lc->clean_bits);
+ dm_free(lc->sync_bits);
+ dm_free(lc);
return 0;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 14/20] Remove dead store in _clog_ctr
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (12 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 13/20] Properly use dm_free Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 15/20] Remove dead assignment in _init_logging Zdenek Kabelac
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Remove unused 'duplicate' pointer.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
daemons/cmirrord/functions.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index d773c42..de80793 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -366,7 +366,6 @@ static int _clog_ctr(char *uuid, uint64_t luid,
uint64_t region_size;
uint64_t region_count;
struct log_c *lc = NULL;
- struct log_c *duplicate;
enum sync log_sync = DEFAULTSYNC;
uint32_t block_on_error = 0;
@@ -448,8 +447,8 @@ static int _clog_ctr(char *uuid, uint64_t luid,
strncpy(lc->uuid, uuid, DM_UUID_LEN);
lc->luid = luid;
- if ((duplicate = get_log(lc->uuid, lc->luid)) ||
- (duplicate = get_pending_log(lc->uuid, lc->luid))) {
+ if (get_log(lc->uuid, lc->luid) ||
+ get_pending_log(lc->uuid, lc->luid)) {
LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
SHORT_UUID(lc->uuid), lc->luid);
dm_free(lc);
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 15/20] Remove dead assignment in _init_logging
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (13 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 14/20] Remove dead store in _clog_ctr Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 16/20] Remove dead store in lvm_run_command Zdenek Kabelac
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
old_mask is not used later - so remove it.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/commands/toolcontext.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c5fc057..9791b45 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -200,7 +200,6 @@ static void _init_logging(struct cmd_context *cmd)
static int _process_config(struct cmd_context *cmd)
{
- mode_t old_umask;
const char *read_ahead;
struct stat st;
const struct config_node *cn;
@@ -211,7 +210,7 @@ static int _process_config(struct cmd_context *cmd)
"global/umask",
DEFAULT_UMASK);
- if ((old_umask = umask((mode_t) cmd->default_settings.umask)) !=
+ if (umask((mode_t) cmd->default_settings.umask) !=
(mode_t) cmd->default_settings.umask)
log_verbose("Set umask to %04o", cmd->default_settings.umask);
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 16/20] Remove dead store in lvm_run_command
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (14 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 15/20] Remove dead assignment in _init_logging Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 17/20] Remove dead assignment in dev_manager_transient Zdenek Kabelac
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
'ret' is not read before its next assignment.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
tools/lvmcmdline.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index dcb1f28..836dbaa 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1064,8 +1064,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
set_cmd_name(cmd->command->name);
if (arg_count(cmd, config_ARG))
- if ((ret = override_config_tree_from_string(cmd,
- arg_str_value(cmd, config_ARG, "")))) {
+ if (override_config_tree_from_string(cmd,
+ arg_str_value(cmd, config_ARG, ""))) {
ret = EINVALID_CMD_LINE;
goto_out;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 17/20] Remove dead assignment in dev_manager_transient
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (15 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 16/20] Remove dead store in lvm_run_command Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 18/20] Remove dead assignment in _remove Zdenek Kabelac
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
'segh' is never read after this assignment - remove it.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/activate/dev_manager.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 0bc658b..f950ca3 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -620,7 +620,7 @@ int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv)
} while (next);
- if ((segh = dm_list_next(&lv->segments, segh))) {
+ if (dm_list_next(&lv->segments, segh)) {
log_error("Number of segments in active LV %s does not "
"match metadata", lv->name);
goto out;
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 18/20] Remove dead assignment in _remove
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (16 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 17/20] Remove dead assignment in dev_manager_transient Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 19/20] Remove unused dev_dir_provided Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 20/20] Add internal error if pointer is uninitialized Zdenek Kabelac
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
'r' is not read - remove it.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
tools/dmsetup.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 56f1579..ae223d6 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -1386,10 +1386,8 @@ error:
static int _remove(int argc, char **argv, void *data __attribute__((unused)))
{
- int r;
-
if (_switches[FORCE_ARG] && argc > 1)
- r = _error_device(argc, argv, NULL);
+ _error_device(argc, argv, NULL);
return _simple(DM_DEVICE_REMOVE, argc > 1 ? argv[1] : NULL, 0, 0);
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 19/20] Remove unused dev_dir_provided
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (17 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 18/20] Remove dead assignment in _remove Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 20/20] Add internal error if pointer is uninitialized Zdenek Kabelac
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
'dev_dir_provided' is unused - remove it.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
tools/toollib.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 0a1a8d4..f76aacd 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -842,7 +842,6 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
const char *vg_name = lv_name;
char *st;
char *dev_dir = cmd->dev_dir;
- int dev_dir_provided = 0;
/* Path supplied? */
if (vg_name && strchr(vg_name, '/')) {
@@ -854,7 +853,6 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
}
if (!strncmp(vg_name, dev_dir, strlen(dev_dir))) {
vg_name += strlen(dev_dir);
- dev_dir_provided = 1;
while (*vg_name == '/')
vg_name++;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 20/20] Add internal error if pointer is uninitialized
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
` (18 preceding siblings ...)
2010-12-16 10:36 ` [PATCH 19/20] Remove unused dev_dir_provided Zdenek Kabelac
@ 2010-12-16 10:36 ` Zdenek Kabelac
19 siblings, 0 replies; 21+ messages in thread
From: Zdenek Kabelac @ 2010-12-16 10:36 UTC (permalink / raw)
To: lvm-devel
Add simple check for existance of 'pl'.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/format_pool/disk_rep.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/lib/format_pool/disk_rep.c b/lib/format_pool/disk_rep.c
index 2c16f50..ca8bfd7 100644
--- a/lib/format_pool/disk_rep.c
+++ b/lib/format_pool/disk_rep.c
@@ -263,6 +263,11 @@ static int _read_vg_pds(const struct format_type *fmt, struct dm_pool *mem,
*/
if (!sp_count) {
/* FIXME pl left uninitialised if !info->dev */
+ if (!pl) {
+ log_error(INTERNAL_ERROR "device is missing");
+ dm_pool_destroy(tmpmem);
+ return 0;
+ }
sp_count = pl->pd.pl_subpools;
if (!(sp_devs =
dm_pool_zalloc(tmpmem,
--
1.7.3.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
end of thread, other threads:[~2010-12-16 10:36 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-16 10:36 [PATCH 00/20] Const fixes Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 01/20] Add more strict const pointers around config tree Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 02/20] Const fixes and additions Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 03/20] Use const char* const * Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 04/20] Remove wrong cast to (char*) Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 05/20] Remove const from destroy callback Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 06/20] Replace void* arithmetic with char* Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 07/20] Use const char * arithmetic for offset calculation Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 08/20] Use const char * for name and old_name in vg Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 09/20] Replace stack trace with failure exit path Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 10/20] Simplify usage fprintf clvmd Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 11/20] Add test for 'read' result Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 12/20] Add test for allocation results for node clonning Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 13/20] Properly use dm_free Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 14/20] Remove dead store in _clog_ctr Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 15/20] Remove dead assignment in _init_logging Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 16/20] Remove dead store in lvm_run_command Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 17/20] Remove dead assignment in dev_manager_transient Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 18/20] Remove dead assignment in _remove Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 19/20] Remove unused dev_dir_provided Zdenek Kabelac
2010-12-16 10:36 ` [PATCH 20/20] Add internal error if pointer is uninitialized Zdenek Kabelac
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.