* [PATCH 1/6] Do not create generate lvol%d name
2010-01-13 13:35 [PATCH 0/6] Code cleanups unrelated to replicator Zdenek Kabelac
@ 2010-01-13 13:35 ` Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 2/6] Intialize cmd in the struct alloc_handle Zdenek Kabelac
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-01-13 13:35 UTC (permalink / raw)
To: lvm-devel
lvol%d is generated for NULL name in lv_create_empty().
So just avoid code duplication.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/metadata/lv_manip.c | 14 +-------------
1 files changed, 1 insertions(+), 13 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8c0ecf9..57c3d08 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2852,8 +2852,6 @@ int lv_create_single(struct volume_group *vg,
uint64_t status = UINT64_C(0);
struct logical_volume *lv, *org = NULL;
int origin_active = 0;
- char lv_name_buf[128];
- const char *lv_name;
struct lvinfo info;
if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) {
@@ -3008,16 +3006,6 @@ int lv_create_single(struct volume_group *vg,
if (!archive(vg))
return 0;
- if (lp->lv_name)
- lv_name = lp->lv_name;
- else {
- if (!generate_lv_name(vg, "lvol%d", lv_name_buf, sizeof(lv_name_buf))) {
- log_error("Failed to generate LV name.");
- return 0;
- }
- lv_name = &lv_name_buf[0];
- }
-
if (lp->tag) {
if (!(vg->fid->fmt->features & FMT_TAGS)) {
log_error("Volume group %s does not support tags",
@@ -3036,7 +3024,7 @@ int lv_create_single(struct volume_group *vg,
}
}
- if (!(lv = lv_create_empty(lv_name ? lv_name : "lvol%d", NULL,
+ if (!(lv = lv_create_empty(lp->lv_name ? lp->lv_name : "lvol%d", NULL,
status, lp->alloc, vg)))
return_0;
--
1.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/6] Intialize cmd in the struct alloc_handle
2010-01-13 13:35 [PATCH 0/6] Code cleanups unrelated to replicator Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 1/6] Do not create generate lvol%d name Zdenek Kabelac
@ 2010-01-13 13:35 ` Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 3/6] Cleanup compiler warning with passing NULL to execvp Zdenek Kabelac
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-01-13 13:35 UTC (permalink / raw)
To: lvm-devel
Move initialization of the 'cmd' member of the struct alloc_handle
before the first potentional return.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 57c3d08..e54c453 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -566,11 +566,11 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
return NULL;
}
+ ah->cmd = cmd;
+
if (segtype_is_virtual(segtype))
return ah;
- ah->cmd = cmd;
-
if (!(ah->mem = dm_pool_create("allocation", 1024))) {
log_error("allocation pool creation failed");
return NULL;
--
1.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/6] Cleanup compiler warning with passing NULL to execvp
2010-01-13 13:35 [PATCH 0/6] Code cleanups unrelated to replicator Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 1/6] Do not create generate lvol%d name Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 2/6] Intialize cmd in the struct alloc_handle Zdenek Kabelac
@ 2010-01-13 13:35 ` Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 4/6] Cleanup compiler pointer cast warning Zdenek Kabelac
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-01-13 13:35 UTC (permalink / raw)
To: lvm-devel
Cleanup gcc warning: null argument where non-null required (arg.2)
As the const declaration of execvp is a bit weird, using local
dmeventdpath string.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
daemons/dmeventd/libdevmapper-event.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c
index 20d925e..4dfdf69 100644
--- a/daemons/dmeventd/libdevmapper-event.c
+++ b/daemons/dmeventd/libdevmapper-event.c
@@ -398,6 +398,8 @@ static int _start_daemon(struct dm_event_fifos *fifos)
int pid, ret = 0;
int status;
struct stat statbuf;
+ char dmeventdpath[] = DMEVENTD_PATH; /* const type for execvp */
+ char * const args[] = { dmeventdpath, NULL };
if (stat(fifos->client_path, &statbuf))
goto start_server;
@@ -437,7 +439,7 @@ static int _start_daemon(struct dm_event_fifos *fifos)
log_error("Unable to fork.");
else if (!pid) {
- execvp(DMEVENTD_PATH, NULL);
+ execvp(args[0], args);
_exit(EXIT_FAILURE);
} else {
if (waitpid(pid, &status, 0) < 0)
--
1.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/6] Cleanup compiler pointer cast warning
2010-01-13 13:35 [PATCH 0/6] Code cleanups unrelated to replicator Zdenek Kabelac
` (2 preceding siblings ...)
2010-01-13 13:35 ` [PATCH 3/6] Cleanup compiler warning with passing NULL to execvp Zdenek Kabelac
@ 2010-01-13 13:35 ` Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 5/6] Cleanup const compiler warning in devmapper Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 6/6] Cleanup const compiler warning in _comp_area Zdenek Kabelac
5 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-01-13 13:35 UTC (permalink / raw)
To: lvm-devel
Cleanup gcc warning: cast from function call of type 'struct dm_list *'
to non-matching type 'long unsigned int'
Casting pointer to long and back to pointer could be easily
handled with just pointer arithmetic.
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 d4c02ca..579cc14 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -754,7 +754,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 *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->head))
+ ((t *)((char*)(v) - (char*)&((t *) 0)->head))
/*
* Given the address v of an instance of 'struct dm_list list' contained in
--
1.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/6] Cleanup const compiler warning in devmapper
2010-01-13 13:35 [PATCH 0/6] Code cleanups unrelated to replicator Zdenek Kabelac
` (3 preceding siblings ...)
2010-01-13 13:35 ` [PATCH 4/6] Cleanup compiler pointer cast warning Zdenek Kabelac
@ 2010-01-13 13:35 ` Zdenek Kabelac
2010-01-13 13:35 ` [PATCH 6/6] Cleanup const compiler warning in _comp_area Zdenek Kabelac
5 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-01-13 13:35 UTC (permalink / raw)
To: lvm-devel
Cleanup gcc warnings:
warning: cast discards qualifiers from pointer target type
API of the library should remain the same as the 'const' is not
mangled into function header for C.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
libdm/libdevmapper.h | 16 ++++++++--------
libdm/libdm-deptree.c | 22 +++++++++++-----------
tools/dmsetup.c | 10 ++++++----
3 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 579cc14..eb5f156 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -307,23 +307,23 @@ struct dm_tree_node *dm_tree_find_node_by_uuid(struct dm_tree *tree,
* Set inverted to use inverted tree.
*/
struct dm_tree_node *dm_tree_next_child(void **handle,
- struct dm_tree_node *parent,
- uint32_t inverted);
+ const struct dm_tree_node *parent,
+ uint32_t inverted);
/*
* Get properties of a node.
*/
-const char *dm_tree_node_get_name(struct dm_tree_node *node);
-const char *dm_tree_node_get_uuid(struct dm_tree_node *node);
-const struct dm_info *dm_tree_node_get_info(struct dm_tree_node *node);
-void *dm_tree_node_get_context(struct dm_tree_node *node);
-int dm_tree_node_size_changed(struct dm_tree_node *dnode);
+const char *dm_tree_node_get_name(const struct dm_tree_node *node);
+const char *dm_tree_node_get_uuid(const struct dm_tree_node *node);
+const struct dm_info *dm_tree_node_get_info(const struct dm_tree_node *node);
+void *dm_tree_node_get_context(const struct dm_tree_node *node);
+int dm_tree_node_size_changed(const struct dm_tree_node *dnode);
/*
* Returns the number of children of the given node (excluding the root node).
* Set inverted for the number of parents.
*/
-int dm_tree_node_num_children(struct dm_tree_node *node, uint32_t inverted);
+int dm_tree_node_num_children(const struct dm_tree_node *node, uint32_t inverted);
/*
* Deactivate a device plus all dependencies.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 7ec5fd2..e4bf9b3 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -201,8 +201,8 @@ void dm_tree_free(struct dm_tree *dtree)
dm_free(dtree);
}
-static int _nodes_are_linked(struct dm_tree_node *parent,
- struct dm_tree_node *child)
+static int _nodes_are_linked(const struct dm_tree_node *parent,
+ const struct dm_tree_node *child)
{
struct dm_tree_link *dlink;
@@ -665,32 +665,32 @@ int dm_tree_add_dev_with_udev_flags(struct dm_tree *dtree, uint32_t major,
return _add_dev(dtree, &dtree->root, major, minor, udev_flags) ? 1 : 0;
}
-const char *dm_tree_node_get_name(struct dm_tree_node *node)
+const char *dm_tree_node_get_name(const struct dm_tree_node *node)
{
return node->info.exists ? node->name : "";
}
-const char *dm_tree_node_get_uuid(struct dm_tree_node *node)
+const char *dm_tree_node_get_uuid(const struct dm_tree_node *node)
{
return node->info.exists ? node->uuid : "";
}
-const struct dm_info *dm_tree_node_get_info(struct dm_tree_node *node)
+const struct dm_info *dm_tree_node_get_info(const struct dm_tree_node *node)
{
return &node->info;
}
-void *dm_tree_node_get_context(struct dm_tree_node *node)
+void *dm_tree_node_get_context(const struct dm_tree_node *node)
{
return node->context;
}
-int dm_tree_node_size_changed(struct dm_tree_node *dnode)
+int dm_tree_node_size_changed(const struct dm_tree_node *dnode)
{
return dnode->props.size_changed;
}
-int dm_tree_node_num_children(struct dm_tree_node *node, uint32_t inverted)
+int dm_tree_node_num_children(const struct dm_tree_node *node, uint32_t inverted)
{
if (inverted) {
if (_nodes_are_linked(&node->dtree->root, node))
@@ -806,11 +806,11 @@ struct dm_tree_node *dm_tree_find_node_by_uuid(struct dm_tree *dtree,
* Set inverted to invert the tree.
*/
struct dm_tree_node *dm_tree_next_child(void **handle,
- struct dm_tree_node *parent,
- uint32_t inverted)
+ const struct dm_tree_node *parent,
+ uint32_t inverted)
{
struct dm_list **dlink = (struct dm_list **) handle;
- struct dm_list *use_list;
+ const struct dm_list *use_list;
if (inverted)
use_list = &parent->used_by;
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index d62e147..78c719e 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -2094,7 +2094,7 @@ static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
void *private)
{
char buf[DM_MAX_TYPE_NAME], *repstr;
- struct dm_info *info = (struct dm_info *) data;
+ const struct dm_info *info = data;
if (!dm_pool_begin_object(mem, 8)) {
log_error("dm_pool_begin_object failed");
@@ -2125,7 +2125,8 @@ static int _dm_tree_names(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field, const void *data,
void *private, unsigned inverted)
{
- struct dm_tree_node *node = (struct dm_tree_node *) data, *parent;
+ const struct dm_tree_node *node = data;
+ struct dm_tree_node *parent;
void *t = NULL;
const char *name;
int first_node = 1;
@@ -2186,7 +2187,8 @@ static int _dm_tree_parents_devs_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
- struct dm_tree_node *node = (struct dm_tree_node *) data, *parent;
+ const struct dm_tree_node *node = data;
+ struct dm_tree_node *parent;
void *t = NULL;
const struct dm_info *info;
int first_node = 1;
@@ -2237,7 +2239,7 @@ static int _dm_tree_parents_count_disp(struct dm_report *rh,
struct dm_report_field *field,
const void *data, void *private)
{
- struct dm_tree_node *node = (struct dm_tree_node *) data;
+ const struct dm_tree_node *node = data;
int num_parent = dm_tree_node_num_children(node, 1);
return dm_report_field_int(rh, field, &num_parent);
--
1.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6/6] Cleanup const compiler warning in _comp_area
2010-01-13 13:35 [PATCH 0/6] Code cleanups unrelated to replicator Zdenek Kabelac
` (4 preceding siblings ...)
2010-01-13 13:35 ` [PATCH 5/6] Cleanup const compiler warning in devmapper Zdenek Kabelac
@ 2010-01-13 13:35 ` Zdenek Kabelac
5 siblings, 0 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-01-13 13:35 UTC (permalink / raw)
To: lvm-devel
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e54c453..583cc3f 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -852,8 +852,8 @@ static int _for_each_pv(struct cmd_context *cmd, struct logical_volume *lv,
static int _comp_area(const void *l, const void *r)
{
- const struct pv_area *lhs = *((const struct pv_area **) l);
- const struct pv_area *rhs = *((const struct pv_area **) r);
+ const struct pv_area *lhs = *((const struct pv_area * const *) l);
+ const struct pv_area *rhs = *((const struct pv_area * const *) r);
if (lhs->count < rhs->count)
return 1;
--
1.6.6
^ permalink raw reply related [flat|nested] 7+ messages in thread