[libxml2] error: Don't use initGenericErrorDefaultFunc



commit a9669679f595fb8c981c1f1298194157f1c993b6
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Fri Sep 9 01:44:00 2022 +0200

    error: Don't use initGenericErrorDefaultFunc
    
    The code in xmlInitParser did only set the error handler if it was NULL
    which should never happen.

 error.c                   | 2 ++
 include/libxml/xmlerror.h | 1 +
 parser.c                  | 3 ---
 runtest.c                 | 5 ++---
 4 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/error.c b/error.c
index 49bd84e0..c96877f4 100644
--- a/error.c
+++ b/error.c
@@ -81,6 +81,8 @@ xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
  * initGenericErrorDefaultFunc:
  * @handler:  the handler
  *
+ * DEPRECATED: Use xmlSetGenericErrorFunc.
+ *
  * Set or reset (if NULL) the default handler for generic errors
  * to the builtin error function.
  */
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index f92b1aee..f8ca8ab8 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -864,6 +864,7 @@ typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr erro
 XMLPUBFUN void XMLCALL
     xmlSetGenericErrorFunc     (void *ctx,
                                 xmlGenericErrorFunc handler);
+XML_DEPRECATED
 XMLPUBFUN void XMLCALL
     initGenericErrorDefaultFunc        (xmlGenericErrorFunc *handler);
 
diff --git a/parser.c b/parser.c
index af0b1171..7bb47366 100644
--- a/parser.c
+++ b/parser.c
@@ -14725,9 +14725,6 @@ xmlInitParser(void) {
 #endif
        xmlInitThreads();
        xmlInitGlobals();
-       if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
-           (xmlGenericError == NULL))
-           initGenericErrorDefaultFunc(NULL);
        xmlInitMemory();
         xmlInitializeDict();
        xmlInitCharEncodingHandlers();
diff --git a/runtest.c b/runtest.c
index 791d624d..ff992951 100644
--- a/runtest.c
+++ b/runtest.c
@@ -2427,12 +2427,11 @@ ignoreGenericError(void *ctx ATTRIBUTE_UNUSED,
 
 static void
 testXPath(const char *str, int xptr, int expr) {
-    xmlGenericErrorFunc handler = ignoreGenericError;
     xmlXPathObjectPtr res;
     xmlXPathContextPtr ctxt;
 
     /* Don't print generic errors to stderr. */
-    initGenericErrorDefaultFunc(&handler);
+    xmlSetGenericErrorFunc(NULL, ignoreGenericError);
 
     nb_tests++;
 #if defined(LIBXML_XPTR_ENABLED)
@@ -2464,7 +2463,7 @@ testXPath(const char *str, int xptr, int expr) {
     xmlXPathFreeContext(ctxt);
 
     /* Reset generic error handler. */
-    initGenericErrorDefaultFunc(NULL);
+    xmlSetGenericErrorFunc(NULL, NULL);
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]