From: Zdenek Kabelac Date: Thu, 1 Sep 2011 14:02:05 +0000 (+0000) Subject: Use const casting when it's needed X-Git-Tag: old-v2_02_89~543 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=d91c270d1c1c099ddaf9ba2bc987e3e490c649a3;p=lvm2.git Use const casting when it's needed Keep the lookup operation const and use const casting at the dm_ function level. --- diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c index d9e41df5a..7b06ca915 100644 --- a/libdm/libdm-config.c +++ b/libdm/libdm-config.c @@ -809,8 +809,8 @@ static char *_dup_tok(struct parser *p) /* * utility functions */ -static struct dm_config_node *_find_config_node(const void *start, - const char *path) +static const struct dm_config_node *_find_config_node(const void *start, + const char *path) { const char *e; const struct dm_config_node *cn = start; @@ -848,15 +848,15 @@ static struct dm_config_node *_find_config_node(const void *start, 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; - struct dm_config_node *cn = NULL; + const struct dm_config_node *cn = NULL; while (cft) { 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, 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)