[Devel] [PATCH 2/2] src/lib/config.c: Fix "cast discards qualifiers from pointer target type" warnings

Dmitry V. Levin ldv at altlinux.org
Mon Feb 19 15:36:11 PST 2007


src/lib/config.c (vps_parse_opt): Remove const qualifier from
"const char *val" argument, because it may be passed to parsers
which in turn may modify it using strtok(3).

src/lib/config.c (parse_setmode, conf_store_str, parse_meminfo,
parse_ub): Add const qualifier to "char *val" argument.

Signed-off-by: Dmitry V. Levin <ldv at altlinux.org>
---
 include/config.h |    2 +-
 src/lib/config.c |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/config.h b/include/config.h
index 1fb2194..1ad1571 100644
--- a/include/config.h
+++ b/include/config.h
@@ -34,7 +34,7 @@ typedef struct vps_config {
 int vps_parse_config(envid_t veid, char *path, vps_param *vps_p,
 	struct mod_action *action);
 int vps_parse_opt(envid_t veid, vps_param *param, int opt,
-	const char *rval, struct mod_action *action);
+	char *rval, struct mod_action *action);
 int vps_save_config(envid_t veid, char *path, vps_param *new_p,
 	vps_param *old_p, struct mod_action *action);
 
diff --git a/src/lib/config.c b/src/lib/config.c
index e2cc7a2..8bc58e7 100644
--- a/src/lib/config.c
+++ b/src/lib/config.c
@@ -277,7 +277,7 @@ static conf_struct *find_conf_line(list_head_t *head, char *name,
 	return NULL;
 }
 
-static int parse_setmode(vps_param *vps_p, char *val)
+static int parse_setmode(vps_param *vps_p, const char *val)
 {
 	if (!strcmp(val, "ignore"))
 		vps_p->opt.setmode = SET_IGNORE;
@@ -335,7 +335,7 @@ int conf_store_strlist(list_head_t *conf, char *name, list_head_t *val)
 	return 0;
 }
 
-int conf_store_str(list_head_t *conf, char *name, char *val)
+int conf_store_str(list_head_t *conf, char *name, const char *val)
 {
 	char *buf;
 	int len;
@@ -579,7 +579,7 @@ int parse_twoul(const char *str, unsigned long *val)
 	return ret;
 }
 /******************** totalmem *************************/
-int parse_meminfo(meminfo_param *param, char *val)
+int parse_meminfo(meminfo_param *param, const char *val)
 {
 	int mode;
 	char mode_nm[32];
@@ -628,7 +628,7 @@ static int store_meminfo(vps_param *old_p, vps_param *vps_p, vps_config *conf,
 	return 0;
 }
 
-int parse_ub(vps_param *vps_p, char *val, int id, int divisor)
+int parse_ub(vps_param *vps_p, const char *val, int id, int divisor)
 {
 	int ret;
 	ub_res res;
@@ -2285,7 +2285,7 @@ int vps_remove_cfg_param(envid_t veid, char *path, char *name)
 }
 
 /********************************************************************/
-int vps_parse_opt(envid_t veid, vps_param *param, int opt, const char *rval,
+int vps_parse_opt(envid_t veid, vps_param *param, int opt, char *rval,
 	struct mod_action *action)
 {
 	int id, ret = 0;
@@ -2293,7 +2293,7 @@ int vps_parse_opt(envid_t veid, vps_param *param, int opt, const char *rval,
 	if (param == NULL)
 		return -1;
 	if ((id = opt_get_by_id(set_opt, opt)) != -1) {
-		ret = parse(veid, param, (char *)rval, id);
+		ret = parse(veid, param, rval, id);
 	} else if (action != NULL) {
 		ret = mod_parse(veid, action, NULL, opt, rval);
 	}
-- 
1.5.0.1.GIT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20070220/eeacfcaa/attachment-0001.sig>


More information about the Devel mailing list