1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

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; int ret;
ctxt = xmlRelaxNGNewParserCtxt(schemas); ctxt = xmlRelaxNGNewParserCtxt(schemas);
xmlRelaxNGSetParserErrors(ctxt, xmlRelaxNGSetParserErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
(xmlRelaxNGValidityErrorFunc) fprintf,
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
relaxngschemas = xmlRelaxNGParse(ctxt); relaxngschemas = xmlRelaxNGParse(ctxt);
xmlRelaxNGFreeParserCtxt(ctxt); xmlRelaxNGFreeParserCtxt(ctxt);
if (relaxngschemas == NULL) { if (relaxngschemas == NULL) {
@ -2375,10 +2372,7 @@ xmlShellRNGValidate(xmlShellCtxtPtr sctxt, char *schemas,
return(-1); return(-1);
} }
vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas); vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
xmlRelaxNGSetValidErrors(vctxt, xmlRelaxNGSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL);
(xmlRelaxNGValidityErrorFunc) fprintf,
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc); ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc);
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", sctxt->filename); fprintf(stderr, "%s validates\n", sctxt->filename);
@ -2647,9 +2641,9 @@ xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
int res = -1; int res = -1;
if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1); if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
vctxt.userData = stderr; vctxt.userData = NULL;
vctxt.error = (xmlValidityErrorFunc) fprintf; vctxt.error = xmlGenericError;
vctxt.warning = (xmlValidityWarningFunc) fprintf; vctxt.warning = xmlGenericError;
if ((dtd == NULL) || (dtd[0] == 0)) { if ((dtd == NULL) || (dtd[0] == 0)) {
res = xmlValidateDocument(&vctxt, ctxt->doc); res = xmlValidateDocument(&vctxt, ctxt->doc);

View File

@ -631,7 +631,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
(channel == xmlParserValidityError) || (channel == xmlParserValidityError) ||
(channel == xmlParserValidityWarning)) (channel == xmlParserValidityWarning))
xmlReportError(to, ctxt, str, NULL, NULL); xmlReportError(to, ctxt, str, NULL, NULL);
else if ((channel == (xmlGenericErrorFunc) fprintf) || else if (((void(*)(void)) channel == (void(*)(void)) fprintf) ||
(channel == xmlGenericErrorDefaultFunc)) (channel == xmlGenericErrorDefaultFunc))
xmlReportError(to, ctxt, str, channel, data); xmlReportError(to, ctxt, str, channel, data);
else else

View File

@ -101,9 +101,7 @@ int main(int argc, char **argv) {
ctxt = xmlRelaxNGNewMemParserCtxt((char *)base,info.st_size); ctxt = xmlRelaxNGNewMemParserCtxt((char *)base,info.st_size);
xmlRelaxNGSetParserErrors(ctxt, xmlRelaxNGSetParserErrors(ctxt,
(xmlRelaxNGValidityErrorFunc) fprintf, xmlGenericError, xmlGenericError, NULL);
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
schema = xmlRelaxNGParse(ctxt); schema = xmlRelaxNGParse(ctxt);
xmlRelaxNGFreeParserCtxt(ctxt); xmlRelaxNGFreeParserCtxt(ctxt);
munmap((char *) base, info.st_size); munmap((char *) base, info.st_size);
@ -112,9 +110,7 @@ int main(int argc, char **argv) {
{ {
ctxt = xmlRelaxNGNewParserCtxt(argv[i]); ctxt = xmlRelaxNGNewParserCtxt(argv[i]);
xmlRelaxNGSetParserErrors(ctxt, xmlRelaxNGSetParserErrors(ctxt,
(xmlRelaxNGValidityErrorFunc) fprintf, xmlGenericError, xmlGenericError, NULL);
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
schema = xmlRelaxNGParse(ctxt); schema = xmlRelaxNGParse(ctxt);
xmlRelaxNGFreeParserCtxt(ctxt); xmlRelaxNGFreeParserCtxt(ctxt);
} }
@ -144,9 +140,7 @@ int main(int argc, char **argv) {
ctxt = xmlRelaxNGNewValidCtxt(schema); ctxt = xmlRelaxNGNewValidCtxt(schema);
xmlRelaxNGSetValidErrors(ctxt, xmlRelaxNGSetValidErrors(ctxt,
(xmlRelaxNGValidityErrorFunc) fprintf, xmlGenericError, xmlGenericError, NULL);
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
ret = xmlRelaxNGValidateDoc(ctxt, doc); ret = xmlRelaxNGValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
printf("%s validates\n", argv[i]); 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); ctxt = xmlSchemaNewMemParserCtxt((char *)base,info.st_size);
xmlSchemaSetParserErrors(ctxt, xmlSchemaSetParserErrors(ctxt,
(xmlSchemaValidityErrorFunc) fprintf, xmlGenericError, xmlGenericError, NULL);
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
schema = xmlSchemaParse(ctxt); schema = xmlSchemaParse(ctxt);
xmlSchemaFreeParserCtxt(ctxt); xmlSchemaFreeParserCtxt(ctxt);
munmap((char *) base, info.st_size); munmap((char *) base, info.st_size);
@ -108,9 +106,7 @@ int main(int argc, char **argv) {
{ {
ctxt = xmlSchemaNewParserCtxt(argv[i]); ctxt = xmlSchemaNewParserCtxt(argv[i]);
xmlSchemaSetParserErrors(ctxt, xmlSchemaSetParserErrors(ctxt,
(xmlSchemaValidityErrorFunc) fprintf, xmlGenericError, xmlGenericError, NULL);
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
schema = xmlSchemaParse(ctxt); schema = xmlSchemaParse(ctxt);
xmlSchemaFreeParserCtxt(ctxt); xmlSchemaFreeParserCtxt(ctxt);
} }
@ -135,9 +131,7 @@ int main(int argc, char **argv) {
ctxt = xmlSchemaNewValidCtxt(schema); ctxt = xmlSchemaNewValidCtxt(schema);
xmlSchemaSetValidErrors(ctxt, xmlSchemaSetValidErrors(ctxt,
(xmlSchemaValidityErrorFunc) fprintf, xmlGenericError, xmlGenericError, NULL);
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
ret = xmlSchemaValidateDoc(ctxt, doc); ret = xmlSchemaValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
printf("%s validates\n", argv[i]); printf("%s validates\n", argv[i]);

View File

@ -1652,10 +1652,7 @@ testSAX(const char *filename) {
xmlSchemaValidCtxtPtr vctxt; xmlSchemaValidCtxtPtr vctxt;
vctxt = xmlSchemaNewValidCtxt(wxschemas); vctxt = xmlSchemaNewValidCtxt(wxschemas);
xmlSchemaSetValidErrors(vctxt, xmlSchemaSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL);
(xmlSchemaValidityErrorFunc) fprintf,
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
xmlSchemaValidateSetFilename(vctxt, filename); xmlSchemaValidateSetFilename(vctxt, filename);
ret = xmlSchemaValidateStream(vctxt, buf, 0, handler, ret = xmlSchemaValidateStream(vctxt, buf, 0, handler,
@ -2760,9 +2757,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
"Couldn't allocate validation context\n"); "Couldn't allocate validation context\n");
exit(-1); exit(-1);
} }
cvp->userData = (void *) stderr; cvp->userData = NULL;
cvp->error = (xmlValidityErrorFunc) fprintf; cvp->error = xmlGenericError;
cvp->warning = (xmlValidityWarningFunc) fprintf; cvp->warning = xmlGenericError;
if ((timing) && (!repeat)) { if ((timing) && (!repeat)) {
startTimer(); startTimer();
@ -2796,9 +2793,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if ((timing) && (!repeat)) { if ((timing) && (!repeat)) {
startTimer(); startTimer();
} }
cvp->userData = (void *) stderr; cvp->userData = NULL;
cvp->error = (xmlValidityErrorFunc) fprintf; cvp->error = xmlGenericError;
cvp->warning = (xmlValidityWarningFunc) fprintf; cvp->warning = xmlGenericError;
if (!xmlValidateDocument(cvp, doc)) { if (!xmlValidateDocument(cvp, doc)) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"Document %s does not validate\n", filename); "Document %s does not validate\n", filename);
@ -2828,10 +2825,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
flag |= XML_SCHEMATRON_OUT_QUIET; flag |= XML_SCHEMATRON_OUT_QUIET;
ctxt = xmlSchematronNewValidCtxt(wxschematron, flag); ctxt = xmlSchematronNewValidCtxt(wxschematron, flag);
#if 0 #if 0
xmlSchematronSetValidErrors(ctxt, xmlSchematronSetValidErrors(ctxt, xmlGenericError, xmlGenericError,
(xmlSchematronValidityErrorFunc) fprintf, NULL);
(xmlSchematronValidityWarningFunc) fprintf,
stderr);
#endif #endif
ret = xmlSchematronValidateDoc(ctxt, doc); ret = xmlSchematronValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
@ -2860,10 +2855,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
} }
ctxt = xmlRelaxNGNewValidCtxt(relaxngschemas); ctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
xmlRelaxNGSetValidErrors(ctxt, xmlRelaxNGSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
(xmlRelaxNGValidityErrorFunc) fprintf,
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
ret = xmlRelaxNGValidateDoc(ctxt, doc); ret = xmlRelaxNGValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", filename); fprintf(stderr, "%s validates\n", filename);
@ -2888,10 +2880,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
} }
ctxt = xmlSchemaNewValidCtxt(wxschemas); ctxt = xmlSchemaNewValidCtxt(wxschemas);
xmlSchemaSetValidErrors(ctxt, xmlSchemaSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
(xmlSchemaValidityErrorFunc) fprintf,
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
ret = xmlSchemaValidateDoc(ctxt, doc); ret = xmlSchemaValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", filename); fprintf(stderr, "%s validates\n", filename);
@ -3552,10 +3541,8 @@ main(int argc, char **argv) {
} }
ctxt = xmlSchematronNewParserCtxt(schematron); ctxt = xmlSchematronNewParserCtxt(schematron);
#if 0 #if 0
xmlSchematronSetParserErrors(ctxt, xmlSchematronSetParserErrors(ctxt, xmlGenericError, xmlGenericError,
(xmlSchematronValidityErrorFunc) fprintf, NULL);
(xmlSchematronValidityWarningFunc) fprintf,
stderr);
#endif #endif
wxschematron = xmlSchematronParse(ctxt); wxschematron = xmlSchematronParse(ctxt);
if (wxschematron == NULL) { if (wxschematron == NULL) {
@ -3585,10 +3572,8 @@ main(int argc, char **argv) {
startTimer(); startTimer();
} }
ctxt = xmlRelaxNGNewParserCtxt(relaxng); ctxt = xmlRelaxNGNewParserCtxt(relaxng);
xmlRelaxNGSetParserErrors(ctxt, xmlRelaxNGSetParserErrors(ctxt, xmlGenericError, xmlGenericError,
(xmlRelaxNGValidityErrorFunc) fprintf, NULL);
(xmlRelaxNGValidityWarningFunc) fprintf,
stderr);
relaxngschemas = xmlRelaxNGParse(ctxt); relaxngschemas = xmlRelaxNGParse(ctxt);
if (relaxngschemas == NULL) { if (relaxngschemas == NULL) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -3611,10 +3596,7 @@ main(int argc, char **argv) {
startTimer(); startTimer();
} }
ctxt = xmlSchemaNewParserCtxt(schema); ctxt = xmlSchemaNewParserCtxt(schema);
xmlSchemaSetParserErrors(ctxt, xmlSchemaSetParserErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
(xmlSchemaValidityErrorFunc) fprintf,
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
wxschemas = xmlSchemaParse(ctxt); wxschemas = xmlSchemaParse(ctxt);
if (wxschemas == NULL) { if (wxschemas == NULL) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,