[libxml2] Ignore function pointer cast warnings



commit 13acadbb1ca1f42a65c6466dca025d4020be192a
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Sun Nov 12 17:28:12 2017 +0100

    Ignore function pointer cast warnings
    
    Use GCC pragmas as these warnings are enabled by -Wpedantic and there's
    no way to disable them selectively.

 libxml.h    |   12 ++++++++++++
 xmlmodule.c |    2 ++
 xpath.c     |    8 ++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/libxml.h b/libxml.h
index 2efa704..64e30f7 100644
--- a/libxml.h
+++ b/libxml.h
@@ -60,6 +60,18 @@ int vfprintf(FILE *, const char *, va_list);
 #include "trio.h"
 #endif
 
+#if defined(__clang__) || \
+    (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406))
+#define XML_IGNORE_PEDANTIC_WARNINGS \
+    _Pragma("GCC diagnostic push") \
+    _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
+#define XML_POP_WARNINGS \
+    _Pragma("GCC diagnostic pop")
+#else
+#define XML_IGNORE_PEDANTIC_WARNINGS
+#define XML_POP_WARNINGS
+#endif
+
 /*
  * Internal variable indicating if a callback has been registered for
  * node creation/destruction. It avoids spending a lot of time in locking
diff --git a/xmlmodule.c b/xmlmodule.c
index e3a8bd6..a95ab66 100644
--- a/xmlmodule.c
+++ b/xmlmodule.c
@@ -340,6 +340,7 @@ xmlModulePlatformClose(void *handle)
 static int
 xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
 {
+XML_IGNORE_PEDANTIC_WARNINGS
 #ifdef _WIN32_WCE
     /*
      * GetProcAddressA seems only available on WinCE
@@ -349,6 +350,7 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
     *symbol = GetProcAddress(handle, name);
 #endif
     return (NULL == *symbol) ? -1 : 0;
+XML_POP_WARNINGS
 }
 
 #endif /* _WIN32 */
diff --git a/xpath.c b/xpath.c
index 413b246..a9f2968 100644
--- a/xpath.c
+++ b/xpath.c
@@ -4880,7 +4880,9 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
        return(-1);
     if (f == NULL)
         return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
-    return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, XML_CAST_FPTR(f)));
+XML_IGNORE_PEDANTIC_WARNINGS
+    return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
+XML_POP_WARNINGS
 }
 
 /**
@@ -4961,7 +4963,9 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
     if (ctxt->funcHash == NULL)
        return(NULL);
 
-    XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
+XML_IGNORE_PEDANTIC_WARNINGS
+    ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
+XML_POP_WARNINGS
     return(ret);
 }
 


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