From 19f0950d30208c4a37fe90b25ed82c5bdc44287a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 1 Jan 2019 16:38:42 +0100 Subject: [PATCH] Fix -Wcast-function-type warnings (GCC 8) Use xmlGenericError instead of fprintf as error handler. It also prints to stderr by default. --- debugXML.c | 16 +++++----------- error.c | 2 +- testRelax.c | 12 +++--------- testSchemas.c | 12 +++--------- xmllint.c | 50 ++++++++++++++++---------------------------------- 5 files changed, 28 insertions(+), 64 deletions(-) diff --git a/debugXML.c b/debugXML.c index c98db0bc..79bb50d1 100644 --- a/debugXML.c +++ b/debugXML.c @@ -2363,10 +2363,7 @@ xmlShellRNGValidate(xmlShellCtxtPtr sctxt, char *schemas, int ret; ctxt = xmlRelaxNGNewParserCtxt(schemas); - xmlRelaxNGSetParserErrors(ctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlRelaxNGSetParserErrors(ctxt, xmlGenericError, xmlGenericError, NULL); relaxngschemas = xmlRelaxNGParse(ctxt); xmlRelaxNGFreeParserCtxt(ctxt); if (relaxngschemas == NULL) { @@ -2375,10 +2372,7 @@ xmlShellRNGValidate(xmlShellCtxtPtr sctxt, char *schemas, return(-1); } vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas); - xmlRelaxNGSetValidErrors(vctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlRelaxNGSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL); ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc); if (ret == 0) { fprintf(stderr, "%s validates\n", sctxt->filename); @@ -2647,9 +2641,9 @@ xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, int res = -1; if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1); - vctxt.userData = stderr; - vctxt.error = (xmlValidityErrorFunc) fprintf; - vctxt.warning = (xmlValidityWarningFunc) fprintf; + vctxt.userData = NULL; + vctxt.error = xmlGenericError; + vctxt.warning = xmlGenericError; if ((dtd == NULL) || (dtd[0] == 0)) { res = xmlValidateDocument(&vctxt, ctxt->doc); diff --git a/error.c b/error.c index 50e9e6f8..9d39f79e 100644 --- a/error.c +++ b/error.c @@ -631,7 +631,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel, (channel == xmlParserValidityError) || (channel == xmlParserValidityWarning)) xmlReportError(to, ctxt, str, NULL, NULL); - else if ((channel == (xmlGenericErrorFunc) fprintf) || + else if (((void(*)(void)) channel == (void(*)(void)) fprintf) || (channel == xmlGenericErrorDefaultFunc)) xmlReportError(to, ctxt, str, channel, data); else diff --git a/testRelax.c b/testRelax.c index 8e94a7a8..3549f938 100644 --- a/testRelax.c +++ b/testRelax.c @@ -101,9 +101,7 @@ int main(int argc, char **argv) { ctxt = xmlRelaxNGNewMemParserCtxt((char *)base,info.st_size); xmlRelaxNGSetParserErrors(ctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlGenericError, xmlGenericError, NULL); schema = xmlRelaxNGParse(ctxt); xmlRelaxNGFreeParserCtxt(ctxt); munmap((char *) base, info.st_size); @@ -112,9 +110,7 @@ int main(int argc, char **argv) { { ctxt = xmlRelaxNGNewParserCtxt(argv[i]); xmlRelaxNGSetParserErrors(ctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlGenericError, xmlGenericError, NULL); schema = xmlRelaxNGParse(ctxt); xmlRelaxNGFreeParserCtxt(ctxt); } @@ -144,9 +140,7 @@ int main(int argc, char **argv) { ctxt = xmlRelaxNGNewValidCtxt(schema); xmlRelaxNGSetValidErrors(ctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlGenericError, xmlGenericError, NULL); ret = xmlRelaxNGValidateDoc(ctxt, doc); if (ret == 0) { printf("%s validates\n", argv[i]); diff --git a/testSchemas.c b/testSchemas.c index b98e6313..fc39862c 100644 --- a/testSchemas.c +++ b/testSchemas.c @@ -97,9 +97,7 @@ int main(int argc, char **argv) { ctxt = xmlSchemaNewMemParserCtxt((char *)base,info.st_size); xmlSchemaSetParserErrors(ctxt, - (xmlSchemaValidityErrorFunc) fprintf, - (xmlSchemaValidityWarningFunc) fprintf, - stderr); + xmlGenericError, xmlGenericError, NULL); schema = xmlSchemaParse(ctxt); xmlSchemaFreeParserCtxt(ctxt); munmap((char *) base, info.st_size); @@ -108,9 +106,7 @@ int main(int argc, char **argv) { { ctxt = xmlSchemaNewParserCtxt(argv[i]); xmlSchemaSetParserErrors(ctxt, - (xmlSchemaValidityErrorFunc) fprintf, - (xmlSchemaValidityWarningFunc) fprintf, - stderr); + xmlGenericError, xmlGenericError, NULL); schema = xmlSchemaParse(ctxt); xmlSchemaFreeParserCtxt(ctxt); } @@ -135,9 +131,7 @@ int main(int argc, char **argv) { ctxt = xmlSchemaNewValidCtxt(schema); xmlSchemaSetValidErrors(ctxt, - (xmlSchemaValidityErrorFunc) fprintf, - (xmlSchemaValidityWarningFunc) fprintf, - stderr); + xmlGenericError, xmlGenericError, NULL); ret = xmlSchemaValidateDoc(ctxt, doc); if (ret == 0) { printf("%s validates\n", argv[i]); diff --git a/xmllint.c b/xmllint.c index d6f5eb0e..970a84ee 100644 --- a/xmllint.c +++ b/xmllint.c @@ -1652,10 +1652,7 @@ testSAX(const char *filename) { xmlSchemaValidCtxtPtr vctxt; vctxt = xmlSchemaNewValidCtxt(wxschemas); - xmlSchemaSetValidErrors(vctxt, - (xmlSchemaValidityErrorFunc) fprintf, - (xmlSchemaValidityWarningFunc) fprintf, - stderr); + xmlSchemaSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL); xmlSchemaValidateSetFilename(vctxt, filename); ret = xmlSchemaValidateStream(vctxt, buf, 0, handler, @@ -2760,9 +2757,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { "Couldn't allocate validation context\n"); exit(-1); } - cvp->userData = (void *) stderr; - cvp->error = (xmlValidityErrorFunc) fprintf; - cvp->warning = (xmlValidityWarningFunc) fprintf; + cvp->userData = NULL; + cvp->error = xmlGenericError; + cvp->warning = xmlGenericError; if ((timing) && (!repeat)) { startTimer(); @@ -2796,9 +2793,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { if ((timing) && (!repeat)) { startTimer(); } - cvp->userData = (void *) stderr; - cvp->error = (xmlValidityErrorFunc) fprintf; - cvp->warning = (xmlValidityWarningFunc) fprintf; + cvp->userData = NULL; + cvp->error = xmlGenericError; + cvp->warning = xmlGenericError; if (!xmlValidateDocument(cvp, doc)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); @@ -2828,10 +2825,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { flag |= XML_SCHEMATRON_OUT_QUIET; ctxt = xmlSchematronNewValidCtxt(wxschematron, flag); #if 0 - xmlSchematronSetValidErrors(ctxt, - (xmlSchematronValidityErrorFunc) fprintf, - (xmlSchematronValidityWarningFunc) fprintf, - stderr); + xmlSchematronSetValidErrors(ctxt, xmlGenericError, xmlGenericError, + NULL); #endif ret = xmlSchematronValidateDoc(ctxt, doc); if (ret == 0) { @@ -2860,10 +2855,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { } ctxt = xmlRelaxNGNewValidCtxt(relaxngschemas); - xmlRelaxNGSetValidErrors(ctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlRelaxNGSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL); ret = xmlRelaxNGValidateDoc(ctxt, doc); if (ret == 0) { fprintf(stderr, "%s validates\n", filename); @@ -2888,10 +2880,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { } ctxt = xmlSchemaNewValidCtxt(wxschemas); - xmlSchemaSetValidErrors(ctxt, - (xmlSchemaValidityErrorFunc) fprintf, - (xmlSchemaValidityWarningFunc) fprintf, - stderr); + xmlSchemaSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL); ret = xmlSchemaValidateDoc(ctxt, doc); if (ret == 0) { fprintf(stderr, "%s validates\n", filename); @@ -3552,10 +3541,8 @@ main(int argc, char **argv) { } ctxt = xmlSchematronNewParserCtxt(schematron); #if 0 - xmlSchematronSetParserErrors(ctxt, - (xmlSchematronValidityErrorFunc) fprintf, - (xmlSchematronValidityWarningFunc) fprintf, - stderr); + xmlSchematronSetParserErrors(ctxt, xmlGenericError, xmlGenericError, + NULL); #endif wxschematron = xmlSchematronParse(ctxt); if (wxschematron == NULL) { @@ -3585,10 +3572,8 @@ main(int argc, char **argv) { startTimer(); } ctxt = xmlRelaxNGNewParserCtxt(relaxng); - xmlRelaxNGSetParserErrors(ctxt, - (xmlRelaxNGValidityErrorFunc) fprintf, - (xmlRelaxNGValidityWarningFunc) fprintf, - stderr); + xmlRelaxNGSetParserErrors(ctxt, xmlGenericError, xmlGenericError, + NULL); relaxngschemas = xmlRelaxNGParse(ctxt); if (relaxngschemas == NULL) { xmlGenericError(xmlGenericErrorContext, @@ -3611,10 +3596,7 @@ main(int argc, char **argv) { startTimer(); } ctxt = xmlSchemaNewParserCtxt(schema); - xmlSchemaSetParserErrors(ctxt, - (xmlSchemaValidityErrorFunc) fprintf, - (xmlSchemaValidityWarningFunc) fprintf, - stderr); + xmlSchemaSetParserErrors(ctxt, xmlGenericError, xmlGenericError, NULL); wxschemas = xmlSchemaParse(ctxt); if (wxschemas == NULL) { xmlGenericError(xmlGenericErrorContext,