ixml: Fix for compiler warnings for size_t and ptrdiff_t.

ixmlparser.c static functions have been reordered.
(cherry picked from commit 58c694f57d3cbb67ae1e14221dbba995a34d2cbb)
This commit is contained in:
Marcelo Roberto Jimenez 2010-11-15 21:29:07 -02:00
parent a15d46e142
commit 297d2ae877
10 changed files with 1628 additions and 1635 deletions

View File

@ -40,8 +40,11 @@ void IxmlPrintf(
; ;
#else /* DEBUG */ #else /* DEBUG */
static UPNP_INLINE void IxmlPrintf( static UPNP_INLINE void IxmlPrintf(
const char* FmtStr, const char *FmtStr,
...) {} ...)
{
FmtStr = FmtStr;
}
#endif /* DEBUG */ #endif /* DEBUG */
@ -59,6 +62,8 @@ static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot, IXML_Node *tmpRoot,
int depth) int depth)
{ {
tmpRoot = tmpRoot;
depth = depth;
} }
#endif #endif

View File

@ -139,7 +139,7 @@ int ixmlDocument_createElementEx(
errCode = IXML_INSUFFICIENT_MEMORY; errCode = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler; goto ErrorHandler;
} }
// set the node fields /* set the node fields */
newElement->n.nodeType = eELEMENT_NODE; newElement->n.nodeType = eELEMENT_NODE;
newElement->n.nodeName = strdup(tagName); newElement->n.nodeName = strdup(tagName);
if (newElement->n.nodeName == NULL) { if (newElement->n.nodeName == NULL) {
@ -229,7 +229,7 @@ int ixmlDocument_createTextNodeEx(
rc = IXML_INSUFFICIENT_MEMORY; rc = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler; goto ErrorHandler;
} }
// initialize the node /* initialize the node */
ixmlNode_init(returnNode); ixmlNode_init(returnNode);
returnNode->nodeName = strdup(TEXTNODENAME); returnNode->nodeName = strdup(TEXTNODENAME);
@ -239,7 +239,7 @@ int ixmlDocument_createTextNodeEx(
rc = IXML_INSUFFICIENT_MEMORY; rc = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler; goto ErrorHandler;
} }
// add in node value /* add in node value */
if (data != NULL) { if (data != NULL) {
returnNode->nodeValue = strdup(data); returnNode->nodeValue = strdup(data);
if (returnNode->nodeValue == NULL) { if (returnNode->nodeValue == NULL) {
@ -295,7 +295,7 @@ int ixmlDocument_createAttributeEx(
ixmlAttr_init(attrNode); ixmlAttr_init(attrNode);
attrNode->n.nodeType = eATTRIBUTE_NODE; attrNode->n.nodeType = eATTRIBUTE_NODE;
// set the node fields /* set the node fields */
attrNode->n.nodeName = strdup(name); attrNode->n.nodeName = strdup(name);
if (attrNode->n.nodeName == NULL) { if (attrNode->n.nodeName == NULL) {
ixmlAttr_free(attrNode); ixmlAttr_free(attrNode);
@ -343,7 +343,7 @@ int ixmlDocument_createAttributeNSEx(
if (errCode != IXML_SUCCESS) { if (errCode != IXML_SUCCESS) {
goto ErrorHandler; goto ErrorHandler;
} }
// set the namespaceURI field /* set the namespaceURI field */
attrNode->n.namespaceURI = strdup(namespaceURI); attrNode->n.namespaceURI = strdup(namespaceURI);
if (attrNode->n.namespaceURI == NULL) { if (attrNode->n.namespaceURI == NULL) {
ixmlAttr_free(attrNode); ixmlAttr_free(attrNode);
@ -351,7 +351,7 @@ int ixmlDocument_createAttributeNSEx(
errCode = IXML_INSUFFICIENT_MEMORY; errCode = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler; goto ErrorHandler;
} }
// set the localName and prefix /* set the localName and prefix */
errCode = errCode =
ixmlNode_setNodeName((IXML_Node *)attrNode, qualifiedName); ixmlNode_setNodeName((IXML_Node *)attrNode, qualifiedName);
if (errCode != IXML_SUCCESS) { if (errCode != IXML_SUCCESS) {
@ -458,7 +458,7 @@ int ixmlDocument_createElementNSEx(
line = __LINE__; line = __LINE__;
goto ErrorHandler; goto ErrorHandler;
} }
// set the namespaceURI field /* set the namespaceURI field */
newElement->n.namespaceURI = strdup(namespaceURI); newElement->n.namespaceURI = strdup(namespaceURI);
if (newElement->n.namespaceURI == NULL) { if (newElement->n.namespaceURI == NULL) {
line = __LINE__; line = __LINE__;
@ -467,7 +467,7 @@ int ixmlDocument_createElementNSEx(
ret = IXML_INSUFFICIENT_MEMORY; ret = IXML_INSUFFICIENT_MEMORY;
goto ErrorHandler; goto ErrorHandler;
} }
// set the localName and prefix /* set the localName and prefix */
ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName); ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
if (ret != IXML_SUCCESS) { if (ret != IXML_SUCCESS) {
line = __LINE__; line = __LINE__;

View File

@ -110,7 +110,7 @@ int ixmlElement_setAttribute(
{ {
IXML_Node *attrNode; IXML_Node *attrNode;
IXML_Attr *newAttrNode; IXML_Attr *newAttrNode;
short errCode = IXML_SUCCESS; int errCode = IXML_SUCCESS;
if (element == NULL || name == NULL || value == NULL) { if (element == NULL || name == NULL || value == NULL) {
errCode = IXML_INVALID_PARAMETER; errCode = IXML_INVALID_PARAMETER;
@ -208,7 +208,8 @@ IXML_Attr *ixmlElement_getAttributeNode(IXML_Element *element, const DOMString n
attrNode = element->n.firstAttr; attrNode = element->n.firstAttr;
while (attrNode != NULL) { while (attrNode != NULL) {
if (strcmp(attrNode->nodeName, name) == 0) { // found it if (strcmp(attrNode->nodeName, name) == 0) {
/* found it */
break; break;
} else { } else {
attrNode = attrNode->nextSibling; attrNode = attrNode->nextSibling;
@ -555,8 +556,8 @@ IXML_Attr *ixmlElement_getAttributeNodeNS(
while (attrNode != NULL) { while (attrNode != NULL) {
if (strcmp(attrNode->localName, localName) == 0 && if (strcmp(attrNode->localName, localName) == 0 &&
strcmp(attrNode->namespaceURI, namespaceURI) == 0) { strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
// found it /* found it */
break; break;
} else { } else {
attrNode = attrNode->nextSibling; attrNode = attrNode->nextSibling;
} }

View File

@ -166,7 +166,7 @@ int ixml_membuf_insert(
size_t buf_len, size_t buf_len,
/*! [in] The point of insertion relative to the beggining of the /*! [in] The point of insertion relative to the beggining of the
* ixml_membuf internal buffer. */ * ixml_membuf internal buffer. */
int index); size_t index);
#endif /* IXML_MEMBUF_H */ #endif /* IXML_MEMBUF_H */

View File

@ -54,37 +54,29 @@ static void copy_with_escape(
/*! [in] The string to copy from. */ /*! [in] The string to copy from. */
const char *p) const char *p)
{ {
int i; size_t i;
int plen; size_t plen;
if (p == NULL) { if (p == NULL)
return; return;
} plen = strlen(p);
for (i = 0; i < plen; ++i) {
plen = strlen( p );
for (i = 0; i < plen; i++) {
switch (p[i]) { switch (p[i]) {
case '<': case '<':
ixml_membuf_append_str(buf, "&lt;"); ixml_membuf_append_str(buf, "&lt;");
break; break;
case '>': case '>':
ixml_membuf_append_str(buf, "&gt;"); ixml_membuf_append_str(buf, "&gt;");
break; break;
case '&': case '&':
ixml_membuf_append_str(buf, "&amp;"); ixml_membuf_append_str(buf, "&amp;");
break; break;
case '\'': case '\'':
ixml_membuf_append_str(buf, "&apos;"); ixml_membuf_append_str(buf, "&apos;");
break; break;
case '\"': case '\"':
ixml_membuf_append_str(buf, "&quot;"); ixml_membuf_append_str(buf, "&quot;");
break; break;
default: default:
ixml_membuf_append(buf, &p[i]); ixml_membuf_append(buf, &p[i]);
break; break;
@ -161,11 +153,11 @@ static void ixmlPrintDomTreeRecursive(
} else { } else {
ixml_membuf_append_str(buf, ">"); ixml_membuf_append_str(buf, ">");
} }
// output the children /* output the children */
ixmlPrintDomTreeRecursive( ixmlPrintDomTreeRecursive(
ixmlNode_getFirstChild(nodeptr), buf); ixmlNode_getFirstChild(nodeptr), buf);
// Done with children. Output the end tag. /* Done with children. Output the end tag. */
ixml_membuf_append_str(buf, "</"); ixml_membuf_append_str(buf, "</");
ixml_membuf_append_str(buf, nodeName); ixml_membuf_append_str(buf, nodeName);
@ -242,11 +234,11 @@ static void ixmlPrintDomTree(
ixml_membuf_append_str(buf, ">"); ixml_membuf_append_str(buf, ">");
} }
// output the children /* output the children */
ixmlPrintDomTreeRecursive( ixmlPrintDomTreeRecursive(
ixmlNode_getFirstChild(nodeptr), buf); ixmlNode_getFirstChild(nodeptr), buf);
// Done with children. Output the end tag. /* Done with children. Output the end tag. */
ixml_membuf_append_str(buf, "</"); ixml_membuf_append_str(buf, "</");
ixml_membuf_append_str(buf, nodeName); ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, ">\r\n"); ixml_membuf_append_str(buf, ">\r\n");
@ -314,10 +306,10 @@ static void ixmlDomTreetoString(
ixml_membuf_append_str(buf, ">"); ixml_membuf_append_str(buf, ">");
} }
// output the children /* output the children */
ixmlPrintDomTreeRecursive(ixmlNode_getFirstChild(nodeptr), buf); ixmlPrintDomTreeRecursive(ixmlNode_getFirstChild(nodeptr), buf);
// Done with children. Output the end tag. /* Done with children. Output the end tag. */
ixml_membuf_append_str(buf, "</"); ixml_membuf_append_str(buf, "</");
ixml_membuf_append_str(buf, nodeName); ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, ">"); ixml_membuf_append_str(buf, ">");

View File

@ -75,10 +75,10 @@ static int ixml_membuf_set_size(
diff = new_length - m->length; diff = new_length - m->length;
alloc_len = MAXVAL(m->size_inc, diff) + m->capacity; alloc_len = MAXVAL(m->size_inc, diff) + m->capacity;
} else { } else {
// decrease length /* decrease length */
assert(new_length <= m->length); assert(new_length <= m->length);
// if diff is 0..m->size_inc, don't free /* if diff is 0..m->size_inc, don't free */
if ((m->capacity - new_length) <= m->size_inc) { if ((m->capacity - new_length) <= m->size_inc) {
return 0; return 0;
} }
@ -135,21 +135,21 @@ int ixml_membuf_assign(
assert(m != NULL); assert(m != NULL);
// set value to null /* set value to null */
if (buf == NULL) { if (buf == NULL) {
ixml_membuf_destroy(m); ixml_membuf_destroy(m);
return IXML_SUCCESS; return IXML_SUCCESS;
} }
// alloc mem /* alloc mem */
return_code = ixml_membuf_set_size(m, buf_len); return_code = ixml_membuf_set_size(m, buf_len);
if (return_code != 0) { if (return_code != 0) {
return return_code; return return_code;
} }
// copy /* copy */
memcpy(m->buf, buf, buf_len); memcpy(m->buf, buf, buf_len);
// null-terminate /* null-terminate */
m->buf[buf_len] = 0; m->buf[buf_len] = 0;
m->length = buf_len; m->length = buf_len;
@ -187,13 +187,13 @@ int ixml_membuf_insert(
INOUT ixml_membuf *m, INOUT ixml_membuf *m,
IN const void *buf, IN const void *buf,
IN size_t buf_len, IN size_t buf_len,
int index) size_t index)
{ {
int return_code = 0; int return_code = 0;
assert(m != NULL); assert(m != NULL);
if (index < 0 || index > (int)m->length) { if (index > m->length) {
return IXML_INDEX_SIZE_ERR; return IXML_INDEX_SIZE_ERR;
} }

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ IXML_Node *ixmlNamedNodeMap_getNamedItem(
IXML_NamedNodeMap *nnMap, IXML_NamedNodeMap *nnMap,
const DOMString name) const DOMString name)
{ {
long index; unsigned long index;
if (nnMap == NULL || name == NULL) { if (nnMap == NULL || name == NULL) {
return NULL; return NULL;
@ -95,7 +95,7 @@ IXML_Node *ixmlNamedNodeMap_getNamedItem(
if (index == IXML_INVALID_ITEM_NUMBER) { if (index == IXML_INVALID_ITEM_NUMBER) {
return NULL; return NULL;
} else { } else {
return ixmlNamedNodeMap_item(nnMap, (unsigned long)index); return ixmlNamedNodeMap_item(nnMap, index);
} }
} }
@ -165,7 +165,7 @@ int ixmlNamedNodeMap_addToNamedNodeMap(
} }
if (*nnMap == NULL) { if (*nnMap == NULL) {
// nodelist is empty /* nodelist is empty */
*nnMap = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap)); *nnMap = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
if (*nnMap == NULL) { if (*nnMap == NULL) {
return IXML_INSUFFICIENT_MEMORY; return IXML_INSUFFICIENT_MEMORY;

View File

@ -542,11 +542,11 @@ int ixmlNode_replaceChild(
if (ixmlNode_allowChildren(nodeptr, newChild) == FALSE) { if (ixmlNode_allowChildren(nodeptr, newChild) == FALSE) {
return IXML_HIERARCHY_REQUEST_ERR; return IXML_HIERARCHY_REQUEST_ERR;
} }
// if newChild was created from a different document /* if newChild was created from a different document */
if (nodeptr->ownerDocument != newChild->ownerDocument) { if (nodeptr->ownerDocument != newChild->ownerDocument) {
return IXML_WRONG_DOCUMENT_ERR; return IXML_WRONG_DOCUMENT_ERR;
} }
// if refChild is not a child of nodeptr /* if refChild is not a child of nodeptr */
if (ixmlNode_isParent(nodeptr, oldChild) != TRUE) { if (ixmlNode_isParent(nodeptr, oldChild) != TRUE) {
return IXML_NOT_FOUND_ERR; return IXML_NOT_FOUND_ERR;
} }
@ -763,6 +763,10 @@ static IXML_Element *ixmlNode_cloneElement(
/*! /*!
* \brief Returns a clone of a document node. * \brief Returns a clone of a document node.
* *
* Currently, the IXML_Document struct is just a node, so this function
* just mallocs the IXML_Document, sets the node type and name. Curiously,
* the parameter nodeptr is not actually used.
*
* \return A clone of a document node. * \return A clone of a document node.
*/ */
static IXML_Document *ixmlNode_cloneDoc( static IXML_Document *ixmlNode_cloneDoc(
@ -781,7 +785,7 @@ static IXML_Document *ixmlNode_cloneDoc(
} }
ixmlDocument_init(newDoc); ixmlDocument_init(newDoc);
docNode = (IXML_Node *) newDoc; docNode = (IXML_Node *)newDoc;
rc = ixmlNode_setNodeName(docNode, DOCUMENTNODENAME); rc = ixmlNode_setNodeName(docNode, DOCUMENTNODENAME);
if (rc != IXML_SUCCESS) { if (rc != IXML_SUCCESS) {
@ -792,6 +796,7 @@ static IXML_Document *ixmlNode_cloneDoc(
newDoc->n.nodeType = eDOCUMENT_NODE; newDoc->n.nodeType = eDOCUMENT_NODE;
return newDoc; return newDoc;
nodeptr = nodeptr;
} }
/*! /*!

View File

@ -57,11 +57,11 @@ IXML_Node *ixmlNodeList_item(
IXML_NodeList *next; IXML_NodeList *next;
unsigned int i; unsigned int i;
// if the list ptr is NULL /* if the list ptr is NULL */
if (nList == NULL) { if (nList == NULL) {
return NULL; return NULL;
} }
// if index is more than list length /* if index is more than list length */
if (index > ixmlNodeList_length(nList) - 1) { if (index > ixmlNodeList_length(nList) - 1) {
return NULL; return NULL;
} }
@ -93,7 +93,7 @@ int ixmlNodeList_addToNodeList(
} }
if (*nList == NULL) { if (*nList == NULL) {
// nodelist is empty /* nodelist is empty */
*nList = (IXML_NodeList *)malloc(sizeof (IXML_NodeList)); *nList = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
if (*nList == NULL) { if (*nList == NULL) {
return IXML_INSUFFICIENT_MEMORY; return IXML_INSUFFICIENT_MEMORY;