php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46323 compilation of simplexml for NetWare breaks
Submitted: 2008-10-16 22:54 UTC Modified: 2008-10-20 19:31 UTC
From: guenter@php.net Assigned: rrichards (profile)
Status: Closed Package: SimpleXML related
PHP Version: 5.2.7RC1 OS: NetWare
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: guenter@php.net
New email:
PHP Version: OS:

 

 [2008-10-16 22:54 UTC] guenter@php.net
Description:
------------
compilation of simplexml for NetWare with CodeWarrior compiler breaks because of different types without using a cast:

Compiling simplexml.c...
simplexml.c:1236: illegal implicit conversion from 'const void *' to
simplexml.c:1236: 'unsigned char *'

Errors caused tool to abort.
make: *** [release/simplexml.obj] Error 1
make: Leaving directory `C:/php5_test/php-5.2.7RC1/ext/simplexml'



Reproduce code:
---------------
compile...

Expected result:
----------------
compile doesnt break.

Actual result:
--------------
compile breaks.

suggested fix:
--- simplexml.c.orig	Thu Sep 11 16:23:34 2008
+++ simplexml.c	Wed Oct 15 19:21:53 2008
@@ -1233,7 +1233,7 @@
 			if (nodeptr->type == XML_TEXT_NODE) {
 				_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
 			} else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
-				_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? nodeptr->ns->href : NULL, 0 TSRMLS_CC);
+				_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (unsigned char*)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
 			} else {
 				_node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
 			}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-20 12:33 UTC] rrichards@php.net
Why is nodeptr->ns->href being detected as const void * by CodeWarrior? 
It is of cont xmlChar * (libxml tree.h).
Does it compile using the following?

xmlChar *href = nodeptr->ns ? nodeptr->ns->href : NULL;
_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, 
(char*)nodeptr->name, href, 0 TSRMLS_CC);

 [2008-10-20 16:36 UTC] guenter@php.net
Hi,
the error message is probably some misleading, and usual for CodeWarrior (grrr).
The real prob is the difference between const xmlChar* and xmlChar*;
the prototype of _node_as_zval() has as 6th param 'xmlChar *nsprefix' defined where - as you already pointed out - nodeptr->ns->href is 'const xmlChar*'; therefore your suggestion fails in same way since it would also assign the (const xmlChar*)nodeptr->ns->href to (xmlChar*)href without a cast.

So I would stay with a proper cast according to the prototype:
--- simplexml.c.orig	Thu Sep 11 16:23:34 2008
+++ simplexml.c	Mon Oct 20 18:21:27 2008
@@ -1233,7 +1233,8 @@
 			if (nodeptr->type == XML_TEXT_NODE) {
 				_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
 			} else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
-				_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? nodeptr->ns->href : NULL, 0 TSRMLS_CC);
+				_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name,
+						nodeptr->ns ? (xmlChar*)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
 			} else {
 				_node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
 			}
 [2008-10-20 19:31 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC