Skip to content

Commit

Permalink
Fix const-correctness with libxml2-2.12.0
Browse files Browse the repository at this point in the history
libxml2-2.12.0 started to return errors as a pointer to a constant
structure and GCC 13.2.1 started to warn like this:

/home/test/createrepo_c/src/xml_parser.c: In function ‘cr_xml_parser_generic’:
/home/test/createrepo_c/src/xml_parser.c:204:35: warning: initialization discards ‘const’ qualifier fro
m pointer target type [-Wdiscarded-qualifiers]
  204 |             xmlErrorPtr xml_err = xmlCtxtGetLastError(parser);
      |                                   ^~~~~~~~~~~~~~~~~~~

This patch fixes it.
  • Loading branch information
ppisar authored and kontura committed Nov 27, 2023
1 parent 3492b93 commit 79ad431
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/xml_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ cr_xml_parser_generic(xmlParserCtxtPtr parser,

if (xmlParseChunk(parser, buf, len, len == 0)) {
ret = CRE_XMLPARSER;
xmlErrorPtr xml_err = xmlCtxtGetLastError(parser);
const xmlError *xml_err = xmlCtxtGetLastError(parser);
g_critical("%s: parsing error '%s': %s",
__func__,
path,
Expand Down Expand Up @@ -272,7 +272,7 @@ cr_xml_parser_generic_from_string(xmlParserCtxtPtr parser,

if (xmlParseChunk(parser, data, block_size, finished)) {
ret = CRE_XMLPARSER;
xmlErrorPtr xml_err = xmlCtxtGetLastError(parser);
const xmlError *xml_err = xmlCtxtGetLastError(parser);
g_critical("%s: parsing error '%s': %s",
__func__,
data,
Expand Down
2 changes: 1 addition & 1 deletion src/xml_parser_main_metadata_together.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ parse_next_section(CR_FILE *target_file, const char *path, cr_ParserData *pd, GE
}
int done = parsed_len == 0;
if (xmlParseChunk(pd->parser, buf, parsed_len, done)) {
xmlErrorPtr xml_err = xmlCtxtGetLastError(pd->parser);
const xmlError *xml_err = xmlCtxtGetLastError(pd->parser);
g_critical("%s: parsing error '%s': %s", __func__, path,
(xml_err) ? xml_err->message : "UNKNOWN_ERROR");
g_set_error(err, ERR_DOMAIN, CRE_XMLPARSER,
Expand Down

0 comments on commit 79ad431

Please sign in to comment.