]> granicus.if.org Git - php/commitdiff
Add do...while(0) for RETURN_* and ZVAL_* APIs
authortwosee <twose@qq.com>
Wed, 12 Jun 2019 10:49:33 +0000 (18:49 +0800)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 12 Jun 2019 14:17:16 +0000 (16:17 +0200)
Closes GH-4255.

14 files changed:
Zend/zend_API.h
Zend/zend_types.h
ext/dom/node.c
ext/dom/xpath.c
ext/exif/exif.c
ext/gd/gd.c
ext/mysqli/mysqli_api.c
ext/odbc/php_odbc.c
ext/reflection/php_reflection.c
ext/simplexml/simplexml.c
ext/soap/soap.c
ext/standard/array.c
ext/standard/hrtime.c
ext/zip/php_zip.c

index d88fa5a85685ce49f0807b1b1d7855a38cc5b28c..fcc7313084f30082cef501dfbcda25eda9885980 100644 (file)
@@ -627,24 +627,24 @@ END_EXTERN_C()
 #define RETVAL_FALSE                                   ZVAL_FALSE(return_value)
 #define RETVAL_TRUE                                    ZVAL_TRUE(return_value)
 
-#define RETURN_BOOL(b)                                         { RETVAL_BOOL(b); return; }
-#define RETURN_NULL()                                  { RETVAL_NULL(); return;}
-#define RETURN_LONG(l)                                         { RETVAL_LONG(l); return; }
-#define RETURN_DOUBLE(d)                               { RETVAL_DOUBLE(d); return; }
-#define RETURN_STR(s)                                  { RETVAL_STR(s); return; }
-#define RETURN_INTERNED_STR(s)                 { RETVAL_INTERNED_STR(s); return; }
-#define RETURN_NEW_STR(s)                              { RETVAL_NEW_STR(s); return; }
-#define RETURN_STR_COPY(s)                             { RETVAL_STR_COPY(s); return; }
-#define RETURN_STRING(s)                               { RETVAL_STRING(s); return; }
-#define RETURN_STRINGL(s, l)                   { RETVAL_STRINGL(s, l); return; }
-#define RETURN_EMPTY_STRING()                  { RETVAL_EMPTY_STRING(); return; }
-#define RETURN_RES(r)                                  { RETVAL_RES(r); return; }
-#define RETURN_ARR(r)                                  { RETVAL_ARR(r); return; }
-#define RETURN_EMPTY_ARRAY()                   { RETVAL_EMPTY_ARRAY(); return; }
-#define RETURN_OBJ(r)                                  { RETVAL_OBJ(r); return; }
-#define RETURN_ZVAL(zv, copy, dtor)            { RETVAL_ZVAL(zv, copy, dtor); return; }
-#define RETURN_FALSE                                   { RETVAL_FALSE; return; }
-#define RETURN_TRUE                                    { RETVAL_TRUE; return; }
+#define RETURN_BOOL(b)                                         do { RETVAL_BOOL(b); return; } while (0)
+#define RETURN_NULL()                                  do { RETVAL_NULL(); return;} while (0)
+#define RETURN_LONG(l)                                         do { RETVAL_LONG(l); return; } while (0)
+#define RETURN_DOUBLE(d)                               do { RETVAL_DOUBLE(d); return; } while (0)
+#define RETURN_STR(s)                                  do { RETVAL_STR(s); return; } while (0)
+#define RETURN_INTERNED_STR(s)                 do { RETVAL_INTERNED_STR(s); return; } while (0)
+#define RETURN_NEW_STR(s)                              do { RETVAL_NEW_STR(s); return; } while (0)
+#define RETURN_STR_COPY(s)                             do { RETVAL_STR_COPY(s); return; } while (0)
+#define RETURN_STRING(s)                               do { RETVAL_STRING(s); return; } while (0)
+#define RETURN_STRINGL(s, l)                   do { RETVAL_STRINGL(s, l); return; } while (0)
+#define RETURN_EMPTY_STRING()                  do { RETVAL_EMPTY_STRING(); return; } while (0)
+#define RETURN_RES(r)                                  do { RETVAL_RES(r); return; } while (0)
+#define RETURN_ARR(r)                                  do { RETVAL_ARR(r); return; } while (0)
+#define RETURN_EMPTY_ARRAY()                   do { RETVAL_EMPTY_ARRAY(); return; } while (0)
+#define RETURN_OBJ(r)                                  do { RETVAL_OBJ(r); return; } while (0)
+#define RETURN_ZVAL(zv, copy, dtor)            do { RETVAL_ZVAL(zv, copy, dtor); return; } while (0)
+#define RETURN_FALSE                                   do { RETVAL_FALSE; return; } while (0)
+#define RETURN_TRUE                                    do { RETVAL_TRUE; return; } while (0)
 
 #define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL)))
 #define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
index 6ba488d88b05b6a85c2fd608b22b1fbb13708639..a4e657513a129a80cc6459c10832c56ceff4fe40 100644 (file)
@@ -770,17 +770,17 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
                        (b) ? IS_TRUE : IS_FALSE;       \
        } while (0)
 
-#define ZVAL_LONG(z, l) {                              \
+#define ZVAL_LONG(z, l) do {                   \
                zval *__z = (z);                                \
                Z_LVAL_P(__z) = l;                              \
                Z_TYPE_INFO_P(__z) = IS_LONG;   \
-       }
+       } while (0)
 
-#define ZVAL_DOUBLE(z, d) {                            \
+#define ZVAL_DOUBLE(z, d) do {                 \
                zval *__z = (z);                                \
                Z_DVAL_P(__z) = d;                              \
                Z_TYPE_INFO_P(__z) = IS_DOUBLE; \
-       }
+       } while (0)
 
 #define ZVAL_STR(z, s) do {                                            \
                zval *__z = (z);                                                \
index 609d1a6116008ea1b3a774e01ac58fb2d40c8386..51153b7a332f0f175a1496d867837af2d3d1cdd1 100644 (file)
@@ -1228,7 +1228,7 @@ PHP_FUNCTION(dom_node_remove_child)
        }
 
        php_dom_throw_error(NOT_FOUND_ERR, stricterror);
-       RETURN_FALSE
+       RETURN_FALSE;
 }
 /* }}} end dom_node_remove_child */
 
index 69fdcb947f7ea9f318bed0327a0924fbd0a50655..063d18f01c5e2892a39eb4485a01a6c9a62897c4 100644 (file)
@@ -329,7 +329,7 @@ PHP_FUNCTION(dom_xpath_register_ns)
        }
 
        if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) {
-               RETURN_FALSE
+               RETURN_FALSE;
        }
        RETURN_TRUE;
 }
index 28899ff736e8228661037b1d74f986169ffec6fc..6aff3dab4e8778f43078869ff887e5ea26de6d0d 100644 (file)
@@ -2681,7 +2681,7 @@ PHP_FUNCTION(exif_tagname)
                RETURN_FALSE;
        }
 
-       RETURN_STRING(szTemp)
+       RETURN_STRING(szTemp);
 }
 /* }}} */
 
index 69d7e426ecaa40fb61211b5fb958ded389834185..c678b4b0998a0b7cce5913bdb2f440a40d942c1b 100644 (file)
@@ -4244,7 +4244,7 @@ static void php_image_filter_scatter(INTERNAL_FUNCTION_PARAMETERS)
 
                efree(colors);
        } else {
-               RETURN_BOOL(gdImageScatter(im, (int) scatter_sub, (int) scatter_plus))
+               RETURN_BOOL(gdImageScatter(im, (int) scatter_sub, (int) scatter_plus));
        }
 }
 
index 12326df3793d5818a0b3bcec037ccae9bcc73f36..af98e7e9b3c738bf4823ba22b1fe77ad2beb2cbc 100644 (file)
@@ -816,7 +816,7 @@ PHP_FUNCTION(mysqli_dump_debug_info)
        }
        MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
 
-       RETURN_BOOL(!mysql_dump_debug_info(mysql->mysql))
+       RETURN_BOOL(!mysql_dump_debug_info(mysql->mysql));
 }
 /* }}} */
 
index 6bd24781b44ea2f9b17c16a844ba74186151cb63..8b6c56a12203f4a82a4b25805a281a457ae53e70 100644 (file)
@@ -2878,7 +2878,7 @@ PHP_FUNCTION(odbc_field_type)
        }
 
        PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)pv_num, SQL_COLUMN_TYPE_NAME, tmp, 31, &tmplen, NULL);
-       RETURN_STRING(tmp)
+       RETURN_STRING(tmp);
 }
 /* }}} */
 
index eebea38bc80991a4fda09201f3c1f28153c5ed65..ee5f5d82b83f29a9f753eb14bd28d60b067eca66 100644 (file)
@@ -5507,7 +5507,7 @@ ZEND_METHOD(reflection_property, isInitialized)
        if (ref->prop.flags & ZEND_ACC_STATIC) {
                member_p = zend_read_static_property_ex(intern->ce, ref->unmangled_name, 1);
                if (member_p) {
-                       RETURN_BOOL(!Z_ISUNDEF_P(member_p))
+                       RETURN_BOOL(!Z_ISUNDEF_P(member_p));
                }
                RETURN_FALSE;
        } else {
index bb8dfb3766159dca253e4ce569e939c45ed92c53..8279770b7f21482be0310ea51fc0035a974eabec 100644 (file)
@@ -1413,7 +1413,7 @@ SXE_METHOD(registerXPathNamespace)
        }
 
        if (xmlXPathRegisterNs(sxe->xpath, (xmlChar *)prefix, (xmlChar *)ns_uri) != 0) {
-               RETURN_FALSE
+               RETURN_FALSE;
        }
        RETURN_TRUE;
 }
index e4fb3c5fd77e26dd1b8d9164b81a9ad3a3be6637..9eebe190963a9040ddb4ee14b3321ef111e71323 100644 (file)
@@ -2250,7 +2250,7 @@ PHP_FUNCTION(is_soap_fault)
            instanceof_function(Z_OBJCE_P(fault), soap_fault_class_entry)) {
                RETURN_TRUE;
        }
-       RETURN_FALSE
+       RETURN_FALSE;
 }
 /* }}} */
 
index 3bbe5bebba86771f42f40e79ced79906ed68ddb6..121d09f40d337fbde4158f9ce5bde3d0944fc686 100644 (file)
@@ -3918,7 +3918,7 @@ PHP_FUNCTION(array_keys)
 
        /* Base case: empty input */
        if (!elem_count) {
-               RETURN_ZVAL(input, 1, 0)
+               RETURN_ZVAL(input, 1, 0);
        }
 
        /* Initialize return array */
index 2a6707f7bda640b80e6af65d5fc5b3159d246569..c6e48d075e784ea93885dad299a46701fe1b7e03 100644 (file)
@@ -183,7 +183,7 @@ PHP_FUNCTION(hrtime)
                add_next_index_long(return_value, (zend_long)(t % (php_hrtime_t)NANO_IN_SEC));
        }
 #else
-       RETURN_FALSE
+       RETURN_FALSE;
 #endif
 }
 /* }}} */
index 65e6a0db225040a7456451c42f344f389f7c6629..6c301cc4907c218acd3cae3b59bcf8bd84036e63 100644 (file)
@@ -1286,7 +1286,7 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
                        RETURN_NEW_STR(buffer);
                } else {
                        zend_string_efree(buffer);
-                       RETURN_EMPTY_STRING()
+                       RETURN_EMPTY_STRING();
                }
        } else {
                RETURN_FALSE;