Skip to content

Commit a8d3a24

Browse files
Jérémie Jourdinfrikilax
authored andcommitted
Improve casting
1 parent e454b5d commit a8d3a24

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/parser.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ xml2jsonc_convert_elements(xmlNode *anode, json_object *jobj)
9696
{
9797
/* JSON string object */
9898
cur_jobj = json_object_new_object();
99-
cur_jstr = json_object_new_string(xmlNodeGetContent(cur_node));
100-
json_object_object_add(jobj, cur_node->name, cur_jstr);
99+
cur_jstr = json_object_new_string((const char *)xmlNodeGetContent(cur_node));
100+
json_object_object_add(jobj, (const char *)cur_node->name, cur_jstr);
101101
}
102102
else
103103
{
104104
/* JSON object */
105105
cur_jobj = json_object_new_object();
106-
json_object_object_add(jobj, cur_node->name, json_object_get(cur_jobj));
106+
json_object_object_add(jobj, (const char *)cur_node->name, json_object_get(cur_jobj));
107107
}
108108
}
109109
xml2jsonc_convert_elements(cur_node->children, cur_jobj);
@@ -2375,17 +2375,16 @@ PARSER_Parse(v2IPTables)
23752375
* added 2021-02-01 by [email protected]
23762376
*/
23772377
PARSER_Parse(XML)
2378-
const size_t i = *offs;
23792378
xmlDocPtr doc = NULL;
23802379
xmlNodePtr root_element = NULL;
23812380

23822381
/* Find the last occurence of '>' in the string */
23832382
char * pch;
2384-
pch=strrchr((xmlChar*) npb->str + *offs, '>');
2383+
pch=strrchr((const char *) npb->str + *offs, '>');
23852384

23862385
/* Truncate the string after the last occurence of '>' */
23872386
int newLen = pch - (npb->str + *offs) + 1;
2388-
xmlChar *const cstr = strndup(npb->str + *offs, newLen);
2387+
char *cstr = strndup(npb->str + *offs, newLen);
23892388
CHKN(cstr);
23902389

23912390
doc=xmlParseDoc((xmlChar*) cstr);

src/v1_parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ xml2jsonc_convert_elements(xmlNode *anode, json_object *jobj)
8383
{
8484
/* JSON string object */
8585
cur_jobj = json_object_new_object();
86-
cur_jstr = json_object_new_string(xmlNodeGetContent(cur_node));
87-
json_object_object_add(jobj, cur_node->name, cur_jstr);
86+
cur_jstr = json_object_new_string((const char *)xmlNodeGetContent(cur_node));
87+
json_object_object_add(jobj, (const char *)cur_node->name, cur_jstr);
8888
}
8989
else
9090
{
9191
/* JSON object */
9292
cur_jobj = json_object_new_object();
93-
json_object_object_add(jobj, cur_node->name, json_object_get(cur_jobj));
93+
json_object_object_add(jobj, (const char *)cur_node->name, json_object_get(cur_jobj));
9494
}
9595
}
9696
xml2jsonc_convert_elements(cur_node->children, cur_jobj);

0 commit comments

Comments
 (0)