Skip to content

Commit d85ab21

Browse files
committed
Fix DOM warnings
1 parent 2b133e9 commit d85ab21

15 files changed

+89
-80
lines changed

ext/dom/attr.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ PHP_METHOD(domattr, __construct)
7878
RETURN_FALSE;
7979
}
8080

81-
nodep = xmlNewProp(NULL, (xmlChar *) name, value);
81+
nodep = xmlNewProp(NULL, (xmlChar *) name, (xmlChar *) value);
8282

8383
if (!nodep) {
8484
php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
@@ -147,7 +147,7 @@ int dom_attr_value_read(dom_object *obj, zval *retval TSRMLS_DC)
147147
}
148148

149149
if ((content = xmlNodeGetContent((xmlNodePtr) attrp)) != NULL) {
150-
ZVAL_STRING(retval, content);
150+
ZVAL_STRING(retval, (char *) content);
151151
xmlFree(content);
152152
} else {
153153
ZVAL_EMPTY_STRING(retval);
@@ -173,7 +173,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC)
173173

174174
str = zval_get_string(newval);
175175

176-
xmlNodeSetContentLen((xmlNodePtr) attrp, str->val, str->len + 1);
176+
xmlNodeSetContentLen((xmlNodePtr) attrp, (xmlChar *) str->val, str->len + 1);
177177

178178
zend_string_release(str);
179179
return SUCCESS;

ext/dom/characterdata.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int dom_characterdata_data_read(dom_object *obj, zval *retval TSRMLS_DC)
8787
}
8888

8989
if ((content = xmlNodeGetContent(nodep)) != NULL) {
90-
ZVAL_STRING(retval, content);
90+
ZVAL_STRING(retval, (char *) content);
9191
xmlFree(content);
9292
} else {
9393
ZVAL_EMPTY_STRING(retval);
@@ -108,7 +108,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval TSRMLS_DC)
108108

109109
str = zval_get_string(newval);
110110

111-
xmlNodeSetContentLen(nodep, str->val, str->len + 1);
111+
xmlNodeSetContentLen(nodep, (xmlChar *) str->val, str->len + 1);
112112

113113
zend_string_release(str);
114114
return SUCCESS;
@@ -187,7 +187,7 @@ PHP_FUNCTION(dom_characterdata_substring_data)
187187
xmlFree(cur);
188188

189189
if (substring) {
190-
RETVAL_STRING(substring);
190+
RETVAL_STRING((char *) substring);
191191
xmlFree(substring);
192192
} else {
193193
RETVAL_EMPTY_STRING();
@@ -223,7 +223,7 @@ PHP_FUNCTION(dom_characterdata_append_data)
223223
}
224224
nodep->properties = NULL;
225225
#else
226-
xmlTextConcat(nodep, arg, arg_len);
226+
xmlTextConcat(nodep, (xmlChar *) arg, arg_len);
227227
#endif
228228
RETURN_TRUE;
229229
}
@@ -268,7 +268,7 @@ PHP_FUNCTION(dom_characterdata_insert_data)
268268
xmlFree(cur);
269269

270270
xmlNodeSetContent(node, first);
271-
xmlNodeAddContent(node, arg);
271+
xmlNodeAddContent(node, (xmlChar *) arg);
272272
xmlNodeAddContent(node, second);
273273

274274
xmlFree(first);
@@ -381,7 +381,7 @@ PHP_FUNCTION(dom_characterdata_replace_data)
381381
second = xmlUTF8Strsub(cur, offset + count, length - offset);
382382
}
383383

384-
substring = xmlStrcat(substring, arg);
384+
substring = xmlStrcat(substring, (xmlChar *) arg);
385385
substring = xmlStrcat(substring, second);
386386

387387
xmlNodeSetContent(node, substring);

ext/dom/document.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ PHP_FUNCTION(dom_document_create_element)
712712
RETURN_FALSE;
713713
}
714714

715-
node = xmlNewDocNode(docp, NULL, name, value);
715+
node = xmlNewDocNode(docp, NULL, (xmlChar *) name, (xmlChar *) value);
716716
if (!node) {
717717
RETURN_FALSE;
718718
}
@@ -931,7 +931,7 @@ PHP_FUNCTION(dom_document_create_entity_reference)
931931
RETURN_FALSE;
932932
}
933933

934-
node = xmlNewReference(docp, name);
934+
node = xmlNewReference(docp, (xmlChar *) name);
935935
if (!node) {
936936
RETURN_FALSE;
937937
}
@@ -1048,9 +1048,9 @@ PHP_FUNCTION(dom_document_create_element_ns)
10481048

10491049
if (errorcode == 0) {
10501050
if (xmlValidateName((xmlChar *) localname, 0) == 0) {
1051-
nodep = xmlNewDocNode (docp, NULL, localname, value);
1051+
nodep = xmlNewDocNode(docp, NULL, (xmlChar *) localname, (xmlChar *) value);
10521052
if (nodep != NULL && uri != NULL) {
1053-
nsptr = xmlSearchNsByHref (nodep->doc, nodep, uri);
1053+
nsptr = xmlSearchNsByHref(nodep->doc, nodep, (xmlChar *) uri);
10541054
if (nsptr == NULL) {
10551055
nsptr = dom_get_ns(nodep, uri, &errorcode, prefix);
10561056
}
@@ -1113,9 +1113,9 @@ PHP_FUNCTION(dom_document_create_attribute_ns)
11131113
errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len);
11141114
if (errorcode == 0) {
11151115
if (xmlValidateName((xmlChar *) localname, 0) == 0) {
1116-
nodep = (xmlNodePtr) xmlNewDocProp(docp, localname, NULL);
1116+
nodep = (xmlNodePtr) xmlNewDocProp(docp, (xmlChar *) localname, NULL);
11171117
if (nodep != NULL && uri_len > 0) {
1118-
nsptr = xmlSearchNsByHref (nodep->doc, root, uri);
1118+
nsptr = xmlSearchNsByHref(nodep->doc, root, (xmlChar *) uri);
11191119
if (nsptr == NULL) {
11201120
nsptr = dom_get_ns(root, uri, &errorcode, prefix);
11211121
}
@@ -1268,15 +1268,15 @@ PHP_METHOD(domdocument, __construct)
12681268
}
12691269

12701270
zend_restore_error_handling(&error_handling TSRMLS_CC);
1271-
docp = xmlNewDoc(version);
1271+
docp = xmlNewDoc((xmlChar *) version);
12721272

12731273
if (!docp) {
12741274
php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
12751275
RETURN_FALSE;
12761276
}
12771277

12781278
if (encoding_len > 0) {
1279-
docp->encoding = (const xmlChar*)xmlStrdup(encoding);
1279+
docp->encoding = (const xmlChar *) xmlStrdup((xmlChar *) encoding);
12801280
}
12811281

12821282
intern = Z_DOMOBJ_P(id);
@@ -1306,8 +1306,8 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p
13061306
int isFileUri = 0;
13071307

13081308
uri = xmlCreateURI();
1309-
escsource = xmlURIEscapeStr(source, ":");
1310-
xmlParseURIReference(uri, escsource);
1309+
escsource = xmlURIEscapeStr((xmlChar *) source, (xmlChar *) ":");
1310+
xmlParseURIReference(uri, (char *) escsource);
13111311
xmlFree(escsource);
13121312

13131313
if (uri->scheme != NULL) {
@@ -1454,7 +1454,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so
14541454
}
14551455
/* If loading from memory, set the base reference uri for the document */
14561456
if (ret && ret->URL == NULL && ctxt->directory != NULL) {
1457-
ret->URL = xmlStrdup(ctxt->directory);
1457+
ret->URL = xmlStrdup((xmlChar *) ctxt->directory);
14581458
}
14591459
} else {
14601460
ret = NULL;
@@ -1642,7 +1642,7 @@ PHP_FUNCTION(dom_document_savexml)
16421642
xmlBufferFree(buf);
16431643
RETURN_FALSE;
16441644
}
1645-
RETVAL_STRING(mem);
1645+
RETVAL_STRING((char *) mem);
16461646
xmlBufferFree(buf);
16471647
} else {
16481648
if (options & LIBXML_SAVE_NOEMPTYTAG) {
@@ -1657,7 +1657,7 @@ PHP_FUNCTION(dom_document_savexml)
16571657
if (!size) {
16581658
RETURN_FALSE;
16591659
}
1660-
RETVAL_STRINGL(mem, size);
1660+
RETVAL_STRINGL((char *) mem, size);
16611661
xmlFree(mem);
16621662
}
16631663
}
@@ -1995,7 +1995,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
19951995
if (mode == DOM_LOAD_FILE) {
19961996
ctxt = htmlCreateFileParserCtxt(source, NULL);
19971997
} else {
1998-
source_len = xmlStrlen(source);
1998+
source_len = xmlStrlen((xmlChar *) source);
19991999
ctxt = htmlCreateMemoryParserCtxt(source, source_len);
20002000
}
20012001

ext/dom/documentfragment.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ PHP_METHOD(domdocumentfragment, appendXML) {
138138
}
139139

140140
if (data) {
141-
err = xmlParseBalancedChunkMemory(nodep->doc, NULL, NULL, 0, data, &lst);
141+
err = xmlParseBalancedChunkMemory(nodep->doc, NULL, NULL, 0, (xmlChar *) data, &lst);
142142
if (err != 0) {
143143
RETURN_FALSE;
144144
}

ext/dom/dom_iterators.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
218218
} else {
219219
goto err;
220220
}
221-
curnode = dom_get_elements_by_tag_name_ns_raw(basenode, objmap->ns, objmap->local, &previndex, iter->index);
221+
curnode = dom_get_elements_by_tag_name_ns_raw(
222+
basenode, (char *) objmap->ns, (char *) objmap->local, &previndex, iter->index);
222223
}
223224
}
224225
} else {
@@ -294,7 +295,8 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
294295
} else {
295296
nodep = nodep->children;
296297
}
297-
curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &curindex, 0);
298+
curnode = dom_get_elements_by_tag_name_ns_raw(
299+
nodep, (char *) objmap->ns, (char *) objmap->local, &curindex, 0);
298300
}
299301
}
300302
} else {

ext/dom/domimplementation.c

+12-8
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,24 @@ PHP_METHOD(domimplementation, createDocumentType)
107107
RETURN_FALSE;
108108
}
109109

110-
if (publicid_len > 0)
111-
pch1 = publicid;
112-
if (systemid_len > 0)
113-
pch2 = systemid;
110+
if (publicid_len > 0) {
111+
pch1 = (xmlChar *) publicid;
112+
}
113+
if (systemid_len > 0) {
114+
pch2 = (xmlChar *) systemid;
115+
}
114116

115117
uri = xmlParseURI(name);
116118
if (uri != NULL && uri->opaque != NULL) {
117-
localname = xmlStrdup(uri->opaque);
119+
localname = xmlStrdup((xmlChar *) uri->opaque);
118120
if (xmlStrchr(localname, (xmlChar) ':') != NULL) {
119121
php_dom_throw_error(NAMESPACE_ERR, 1 TSRMLS_CC);
120122
xmlFreeURI(uri);
121123
xmlFree(localname);
122124
RETURN_FALSE;
123125
}
124126
} else {
125-
localname = xmlStrdup(name);
127+
localname = xmlStrdup((xmlChar *) name);
126128
}
127129

128130
/* TODO: Test that localname has no invalid chars
@@ -182,7 +184,9 @@ PHP_METHOD(domimplementation, createDocument)
182184

183185
if (name_len > 0) {
184186
errorcode = dom_check_qname(name, &localname, &prefix, 1, name_len);
185-
if (errorcode == 0 && uri_len > 0 && ((nsptr = xmlNewNs(NULL, uri, prefix)) == NULL)) {
187+
if (errorcode == 0 && uri_len > 0
188+
&& ((nsptr = xmlNewNs(NULL, (xmlChar *) uri, (xmlChar *) prefix)) == NULL)
189+
) {
186190
errorcode = NAMESPACE_ERR;
187191
}
188192
}
@@ -217,7 +221,7 @@ PHP_METHOD(domimplementation, createDocument)
217221
}
218222

219223
if (localname != NULL) {
220-
nodep = xmlNewDocNode (docp, nsptr, localname, NULL);
224+
nodep = xmlNewDocNode(docp, nsptr, (xmlChar *) localname, NULL);
221225
if (!nodep) {
222226
if (doctype != NULL) {
223227
docp->intSubset = NULL;

ext/dom/element.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ PHP_METHOD(domelement, __construct)
201201
}
202202
} else {
203203
/* If you don't pass a namespace uri, then you can't set a prefix */
204-
localname = xmlSplitQName2((xmlChar *)name, (xmlChar **) &prefix);
204+
localname = (char *) xmlSplitQName2((xmlChar *) name, (xmlChar **) &prefix);
205205
if (prefix != NULL) {
206206
xmlFree(localname);
207207
xmlFree(prefix);

ext/dom/entity.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int dom_entity_notation_name_read(dom_object *obj, zval *retval TSRMLS_DC)
107107
if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
108108
ZVAL_NULL(retval);
109109
} else {
110-
content = xmlNodeGetContent((xmlNodePtr) nodep);
110+
content = (char *) xmlNodeGetContent((xmlNodePtr) nodep);
111111
ZVAL_STRING(retval, content);
112112
xmlFree(content);
113113
}

ext/dom/entityreference.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ PHP_METHOD(domentityreference, __construct)
7070
RETURN_FALSE;
7171
}
7272

73-
node = xmlNewReference(NULL, name);
73+
node = xmlNewReference(NULL, (xmlChar *) name);
7474

7575
if (!node) {
7676
php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);

ext/dom/namednodemap.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ PHP_FUNCTION(dom_namednodemap_get_named_item)
149149
objmap->nodetype == XML_ENTITY_NODE) {
150150
if (objmap->ht) {
151151
if (objmap->nodetype == XML_ENTITY_NODE) {
152-
itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, named);
152+
itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, (xmlChar *) named);
153153
} else {
154-
notep = (xmlNotation *)xmlHashLookup(objmap->ht, named);
154+
notep = (xmlNotation *)xmlHashLookup(objmap->ht, (xmlChar *) named);
155155
if (notep) {
156156
itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID);
157157
}
@@ -160,7 +160,7 @@ PHP_FUNCTION(dom_namednodemap_get_named_item)
160160
} else {
161161
nodep = dom_object_get_node(objmap->baseobj);
162162
if (nodep) {
163-
itemnode = (xmlNodePtr)xmlHasProp(nodep, named);
163+
itemnode = (xmlNodePtr)xmlHasProp(nodep, (xmlChar *) named);
164164
}
165165
}
166166
}
@@ -282,9 +282,9 @@ PHP_FUNCTION(dom_namednodemap_get_named_item_ns)
282282
objmap->nodetype == XML_ENTITY_NODE) {
283283
if (objmap->ht) {
284284
if (objmap->nodetype == XML_ENTITY_NODE) {
285-
itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, named);
285+
itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, (xmlChar *) named);
286286
} else {
287-
notep = (xmlNotation *)xmlHashLookup(objmap->ht, named);
287+
notep = (xmlNotation *)xmlHashLookup(objmap->ht, (xmlChar *) named);
288288
if (notep) {
289289
itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID);
290290
}
@@ -293,7 +293,7 @@ PHP_FUNCTION(dom_namednodemap_get_named_item_ns)
293293
} else {
294294
nodep = dom_object_get_node(objmap->baseobj);
295295
if (nodep) {
296-
itemnode = (xmlNodePtr)xmlHasNsProp(nodep, named, uri);
296+
itemnode = (xmlNodePtr)xmlHasNsProp(nodep, (xmlChar *) named, (xmlChar *) uri);
297297
}
298298
}
299299
}

0 commit comments

Comments
 (0)