mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
Fix list callback signatures
Make sure that all parameters and return values of list callback functions exactly match the callback function type. This is required to pass clang's Control Flow Integrity checks and to allow compilation to asm.js with Emscripten. Also change the `user` parameter type from `const void *` to `void *`.
This commit is contained in:
parent
e03f0a199a
commit
4dd6d7a58e
29
c14n.c
29
c14n.c
@ -513,8 +513,10 @@ xmlC14NIsXmlNs(xmlNsPtr ns)
|
||||
* Returns -1 if ns1 < ns2, 0 if ns1 == ns2 or 1 if ns1 > ns2.
|
||||
*/
|
||||
static int
|
||||
xmlC14NNsCompare(xmlNsPtr ns1, xmlNsPtr ns2)
|
||||
xmlC14NNsCompare(const void *data1, const void *data2)
|
||||
{
|
||||
const xmlNsPtr ns1 = (const xmlNsPtr) data1;
|
||||
const xmlNsPtr ns2 = (const xmlNsPtr) data2;
|
||||
if (ns1 == ns2)
|
||||
return (0);
|
||||
if (ns1 == NULL)
|
||||
@ -559,6 +561,11 @@ xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
xmlC14NPrintNamespacesWalker(const void *ns, void *ctx) {
|
||||
return xmlC14NPrintNamespaces((const xmlNsPtr) ns, (xmlC14NCtxPtr) ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlC14NProcessNamespacesAxis:
|
||||
* @ctx: the C14N context
|
||||
@ -615,7 +622,7 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
|
||||
/*
|
||||
* Create a sorted list to store element namespaces
|
||||
*/
|
||||
list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare);
|
||||
list = xmlListCreate(NULL, xmlC14NNsCompare);
|
||||
if (list == NULL) {
|
||||
xmlC14NErrInternal("creating namespaces list (c14n)");
|
||||
return (-1);
|
||||
@ -663,7 +670,7 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
|
||||
/*
|
||||
* print out all elements from list
|
||||
*/
|
||||
xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
|
||||
xmlListWalk(list, xmlC14NPrintNamespacesWalker, (void *) ctx);
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
@ -728,7 +735,7 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
|
||||
/*
|
||||
* Create a sorted list to store element namespaces
|
||||
*/
|
||||
list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare);
|
||||
list = xmlListCreate(NULL, xmlC14NNsCompare);
|
||||
if (list == NULL) {
|
||||
xmlC14NErrInternal("creating namespaces list (exc c14n)");
|
||||
return (-1);
|
||||
@ -840,7 +847,7 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
|
||||
/*
|
||||
* print out all elements from list
|
||||
*/
|
||||
xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
|
||||
xmlListWalk(list, xmlC14NPrintNamespacesWalker, (void *) ctx);
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
@ -879,8 +886,10 @@ xmlC14NIsXmlAttr(xmlAttrPtr attr)
|
||||
* Returns -1 if attr1 < attr2, 0 if attr1 == attr2 or 1 if attr1 > attr2.
|
||||
*/
|
||||
static int
|
||||
xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2)
|
||||
xmlC14NAttrsCompare(const void *data1, const void *data2)
|
||||
{
|
||||
const xmlAttrPtr attr1 = (const xmlAttrPtr) data1;
|
||||
const xmlAttrPtr attr2 = (const xmlAttrPtr) data2;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
@ -931,8 +940,10 @@ xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2)
|
||||
* Returns 1 on success or 0 on fail.
|
||||
*/
|
||||
static int
|
||||
xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
|
||||
xmlC14NPrintAttrs(const void *data, void *user)
|
||||
{
|
||||
const xmlAttrPtr attr = (const xmlAttrPtr) data;
|
||||
xmlC14NCtxPtr ctx = (xmlC14NCtxPtr) user;
|
||||
xmlChar *value;
|
||||
xmlChar *buffer;
|
||||
|
||||
@ -1142,7 +1153,7 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
|
||||
/*
|
||||
* Create a sorted list to store element attributes
|
||||
*/
|
||||
list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NAttrsCompare);
|
||||
list = xmlListCreate(NULL, xmlC14NAttrsCompare);
|
||||
if (list == NULL) {
|
||||
xmlC14NErrInternal("creating attributes list");
|
||||
return (-1);
|
||||
@ -1331,7 +1342,7 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
|
||||
/*
|
||||
* print out all elements from list
|
||||
*/
|
||||
xmlListWalk(list, (xmlListWalker) xmlC14NPrintAttrs, (const void *) ctx);
|
||||
xmlListWalk(list, xmlC14NPrintAttrs, (void *) ctx);
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
|
@ -49,7 +49,7 @@ typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
|
||||
*
|
||||
* Returns 0 to stop walking the list, 1 otherwise.
|
||||
*/
|
||||
typedef int (*xmlListWalker) (const void *data, const void *user);
|
||||
typedef int (*xmlListWalker) (const void *data, void *user);
|
||||
|
||||
/* Creation/Deletion */
|
||||
XMLPUBFUN xmlListPtr XMLCALL
|
||||
@ -110,11 +110,11 @@ XMLPUBFUN void XMLCALL
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
const void *user);
|
||||
void *user);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListReverseWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
const void *user);
|
||||
void *user);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListMerge (xmlListPtr l1,
|
||||
xmlListPtr l2);
|
||||
|
4
list.c
4
list.c
@ -673,7 +673,7 @@ xmlListSort(xmlListPtr l)
|
||||
* apply the walker function to it
|
||||
*/
|
||||
void
|
||||
xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
|
||||
xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user) {
|
||||
xmlLinkPtr lk;
|
||||
|
||||
if ((l == NULL) || (walker == NULL))
|
||||
@ -694,7 +694,7 @@ xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
|
||||
* apply the walker function to it
|
||||
*/
|
||||
void
|
||||
xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
|
||||
xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, void *user) {
|
||||
xmlLinkPtr lk;
|
||||
|
||||
if ((l == NULL) || (walker == NULL))
|
||||
|
4
valid.c
4
valid.c
@ -2888,7 +2888,7 @@ xmlFreeRefTableEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
|
||||
* Returns 0 to abort the walk or 1 to continue
|
||||
*/
|
||||
static int
|
||||
xmlWalkRemoveRef(const void *data, const void *user)
|
||||
xmlWalkRemoveRef(const void *data, void *user)
|
||||
{
|
||||
xmlAttrPtr attr0 = ((xmlRefPtr)data)->attr;
|
||||
xmlAttrPtr attr1 = ((xmlRemoveMemoPtr)user)->ap;
|
||||
@ -6555,7 +6555,7 @@ xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
|
||||
* Returns 0 to abort the walk or 1 to continue
|
||||
*/
|
||||
static int
|
||||
xmlWalkValidateList(const void *data, const void *user)
|
||||
xmlWalkValidateList(const void *data, void *user)
|
||||
{
|
||||
xmlValidateMemoPtr memo = (xmlValidateMemoPtr)user;
|
||||
xmlValidateRef((xmlRefPtr)data, memo->ctxt, memo->name);
|
||||
|
@ -190,9 +190,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
|
||||
}
|
||||
memset(ret, 0, (size_t) sizeof(xmlTextWriter));
|
||||
|
||||
ret->nodes = xmlListCreate((xmlListDeallocator)
|
||||
xmlFreeTextWriterStackEntry,
|
||||
(xmlListDataCompare)
|
||||
ret->nodes = xmlListCreate(xmlFreeTextWriterStackEntry,
|
||||
xmlCmpTextWriterStackEntry);
|
||||
if (ret->nodes == NULL) {
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
@ -201,9 +199,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret->nsstack = xmlListCreate((xmlListDeallocator)
|
||||
xmlFreeTextWriterNsStackEntry,
|
||||
(xmlListDataCompare)
|
||||
ret->nsstack = xmlListCreate(xmlFreeTextWriterNsStackEntry,
|
||||
xmlCmpTextWriterNsStackEntry);
|
||||
if (ret->nsstack == NULL) {
|
||||
xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
|
||||
|
Loading…
x
Reference in New Issue
Block a user