1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Use const casting when it's needed

Keep the lookup operation const and use const casting at the dm_ function level.
This commit is contained in:
Zdenek Kabelac 2011-09-01 14:02:05 +00:00
parent 4ea01630ae
commit 441edcb50a

View File

@ -809,7 +809,7 @@ static char *_dup_tok(struct parser *p)
/* /*
* utility functions * utility functions
*/ */
static struct dm_config_node *_find_config_node(const void *start, static const struct dm_config_node *_find_config_node(const void *start,
const char *path) const char *path)
{ {
const char *e; const char *e;
@ -848,15 +848,15 @@ static struct dm_config_node *_find_config_node(const void *start,
path = e; path = e;
} }
return (struct dm_config_node *) cn_found; return cn_found;
} }
typedef struct dm_config_node *_node_lookup_fn(const void *start, const char *path); typedef const struct dm_config_node *_node_lookup_fn(const void *start, const char *path);
static struct dm_config_node *_find_first_config_node(const void *start, const char *path) static const struct dm_config_node *_find_first_config_node(const void *start, const char *path)
{ {
const struct dm_config_tree *cft = start; const struct dm_config_tree *cft = start;
struct dm_config_node *cn = NULL; const struct dm_config_node *cn = NULL;
while (cft) { while (cft) {
if ((cn = _find_config_node(cft->root, path))) if ((cn = _find_config_node(cft->root, path)))
@ -976,7 +976,7 @@ static int _find_config_bool(const void *start, _node_lookup_fn find,
struct dm_config_node *dm_config_find_node(struct dm_config_node *cn, struct dm_config_node *dm_config_find_node(struct dm_config_node *cn,
const char *path) const char *path)
{ {
return _find_config_node(cn, path); return (struct dm_config_node *) _find_config_node(cn, path);
} }
int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail) int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail)