Skip to content

Commit

Permalink
Improve casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérémie Jourdin authored and frikilax committed Oct 12, 2021
1 parent e454b5d commit a8d3a24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ xml2jsonc_convert_elements(xmlNode *anode, json_object *jobj)
{
/* JSON string object */
cur_jobj = json_object_new_object();
cur_jstr = json_object_new_string(xmlNodeGetContent(cur_node));
json_object_object_add(jobj, cur_node->name, cur_jstr);
cur_jstr = json_object_new_string((const char *)xmlNodeGetContent(cur_node));
json_object_object_add(jobj, (const char *)cur_node->name, cur_jstr);
}
else
{
/* JSON object */
cur_jobj = json_object_new_object();
json_object_object_add(jobj, cur_node->name, json_object_get(cur_jobj));
json_object_object_add(jobj, (const char *)cur_node->name, json_object_get(cur_jobj));
}
}
xml2jsonc_convert_elements(cur_node->children, cur_jobj);
Expand Down Expand Up @@ -2375,17 +2375,16 @@ PARSER_Parse(v2IPTables)
* added 2021-02-01 by jeremie.jourdin@advens.fr
*/
PARSER_Parse(XML)
const size_t i = *offs;
xmlDocPtr doc = NULL;
xmlNodePtr root_element = NULL;

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

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

doc=xmlParseDoc((xmlChar*) cstr);
Expand Down
6 changes: 3 additions & 3 deletions src/v1_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ xml2jsonc_convert_elements(xmlNode *anode, json_object *jobj)
{
/* JSON string object */
cur_jobj = json_object_new_object();
cur_jstr = json_object_new_string(xmlNodeGetContent(cur_node));
json_object_object_add(jobj, cur_node->name, cur_jstr);
cur_jstr = json_object_new_string((const char *)xmlNodeGetContent(cur_node));
json_object_object_add(jobj, (const char *)cur_node->name, cur_jstr);
}
else
{
/* JSON object */
cur_jobj = json_object_new_object();
json_object_object_add(jobj, cur_node->name, json_object_get(cur_jobj));
json_object_object_add(jobj, (const char *)cur_node->name, json_object_get(cur_jobj));
}
}
xml2jsonc_convert_elements(cur_node->children, cur_jobj);
Expand Down

0 comments on commit a8d3a24

Please sign in to comment.