Fix -Wcast-function-type warnings (GCC 8)

Use xmlGenericError instead of fprintf as error handler. It also prints
to stderr by default.
This commit is contained in:
Nick Wellnhofer 2019-01-01 16:38:42 +01:00
parent 8919885ff9
commit 19f0950d30
5 changed files with 28 additions and 64 deletions

View File

@ -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);

View File

@ -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

View File

@ -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]);

View File

@ -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]);

View File

@ -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,