iliaa                                    Mon, 08 Aug 2011 12:29:32 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=314493

Log:
Deadcode & sizeof fix for issues found by coverity
(different patch for 5.4+ will follow shortly)

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/dom/node.c
    U   php/php-src/branches/PHP_5_3/ext/dom/php_dom.c
    U   php/php-src/branches/PHP_5_3/ext/dom/xml_common.h

Modified: php/php-src/branches/PHP_5_3/ext/dom/node.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dom/node.c 2011-08-08 12:25:51 UTC (rev 
314492)
+++ php/php-src/branches/PHP_5_3/ext/dom/node.c 2011-08-08 12:29:32 UTC (rev 
314493)
@@ -998,7 +998,7 @@
 */
 PHP_FUNCTION(dom_node_insert_before)
 {
-       zval *id, *node, *ref = NULL, *rv = NULL;
+       zval *id, *node, *ref = NULL;
        xmlNodePtr child, new_child, parentp, refp;
        dom_object *intern, *childobj, *refpobj;
        int ret, stricterror;
@@ -1087,7 +1087,7 @@
                                        xmlUnlinkNode((xmlNodePtr) lastattr);
                                        
php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
                                } else {
-                                       DOM_RET_OBJ(rv, child, &ret, intern);
+                                       DOM_RET_OBJ_EX(child, &ret, intern);
                                        return;
                                }
                        }
@@ -1129,7 +1129,7 @@
                                        xmlUnlinkNode((xmlNodePtr) lastattr);
                                        
php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
                                } else {
-                                       DOM_RET_OBJ(rv, child, &ret, intern);
+                                       DOM_RET_OBJ_EX(child, &ret, intern);
                                        return;
                                }
                        }
@@ -1148,7 +1148,7 @@

        dom_reconcile_ns(parentp->doc, new_child);

-       DOM_RET_OBJ(rv, new_child, &ret, intern);
+       DOM_RET_OBJ_EX(new_child, &ret, intern);

 }
 /* }}} end dom_node_insert_before */
@@ -1212,9 +1212,6 @@
        }

        if (foundoldchild) {
-               xmlNodePtr node;
-               zval *rv = NULL;
-
                if (newchild->type == XML_DOCUMENT_FRAG_NODE) {
                        xmlNodePtr prevsib, nextsib;
                        prevsib = oldchild->prev;
@@ -1232,10 +1229,10 @@
                                newchildobj->document = intern->document;
                                
php_libxml_increment_doc_ref((php_libxml_node_object *)newchildobj, NULL 
TSRMLS_CC);
                        }
-                       node = xmlReplaceNode(oldchild, newchild);
+                       xmlReplaceNode(oldchild, newchild);
                        dom_reconcile_ns(nodep->doc, newchild);
                }
-               DOM_RET_OBJ(rv, oldchild, &ret, intern);
+               DOM_RET_OBJ_EX(oldchild, &ret, intern);
                return;
        } else {
                php_dom_throw_error(NOT_FOUND_ERR, 
dom_get_strict_error(intern->document) TSRMLS_CC);
@@ -1283,9 +1280,8 @@

        while (children) {
                if (children == child) {
-                       zval *rv = NULL;
                        xmlUnlinkNode(child);
-                       DOM_RET_OBJ(rv, child, &ret, intern);
+                       DOM_RET_OBJ_EX(child, &ret, intern);
                        return;
                }
                children = children->next;
@@ -1302,7 +1298,7 @@
 */
 PHP_FUNCTION(dom_node_append_child)
 {
-       zval *id, *node, *rv = NULL;
+       zval *id, *node;
        xmlNodePtr child, nodep, new_child = NULL;
        dom_object *intern, *childobj;
        int ret, stricterror;
@@ -1393,7 +1389,7 @@

        dom_reconcile_ns(nodep->doc, new_child);

-       DOM_RET_OBJ(rv, new_child, &ret, intern);
+       DOM_RET_OBJ_EX(new_child, &ret, intern);
 }
 /* }}} end dom_node_append_child */

@@ -1431,7 +1427,6 @@
 */
 PHP_FUNCTION(dom_node_clone_node)
 {
-       zval *rv = NULL;
        zval *id;
        xmlNode *n, *node;
        int ret;
@@ -1483,7 +1478,7 @@
                intern = NULL;
        }

-       DOM_RET_OBJ(rv, node, &ret, intern);
+       DOM_RET_OBJ_EX(node, &ret, intern);
 }
 /* }}} end dom_node_clone_node */


Modified: php/php-src/branches/PHP_5_3/ext/dom/php_dom.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dom/php_dom.c      2011-08-08 12:25:51 UTC 
(rev 314492)
+++ php/php-src/branches/PHP_5_3/ext/dom/php_dom.c      2011-08-08 12:29:32 UTC 
(rev 314493)
@@ -212,7 +212,7 @@
                        zend_hash_init(doc_props->classmap, 0, NULL, NULL, 0);
                }
                if (ce) {
-                       return zend_hash_update(doc_props->classmap, 
basece->name, basece->name_length + 1, &ce, sizeof(ce), NULL);
+                       return zend_hash_update(doc_props->classmap, 
basece->name, basece->name_length + 1, &ce, sizeof(zend_class_entry *), NULL);
                } else {
                        zend_hash_del(doc_props->classmap, basece->name, 
basece->name_length + 1);
                }

Modified: php/php-src/branches/PHP_5_3/ext/dom/xml_common.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dom/xml_common.h   2011-08-08 12:25:51 UTC 
(rev 314492)
+++ php/php-src/branches/PHP_5_3/ext/dom/xml_common.h   2011-08-08 12:29:32 UTC 
(rev 314493)
@@ -78,12 +78,14 @@
        } \
 }

-#define DOM_RET_OBJ(zval, obj, ret, domobject) \
-       if (NULL == (zval = php_dom_create_object(obj, ret, zval, return_value, 
domobject TSRMLS_CC))) { \
+#define DOM_RET_OBJ_EX(obj, ret, domobject) \
+       if (!php_dom_create_object(obj, ret, NULL, return_value, domobject 
TSRMLS_CC)) { \
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create 
required DOM object"); \
                RETURN_FALSE; \
        }

+#define DOM_RET_OBJ(zval, obj, ret, domobject) DOM_RET_OBJ_EX(obj, ret, 
domobject)
+
 #define DOM_GET_THIS(zval) \
        if (NULL == (zval = getThis())) { \
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object 
missing"); \

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to