Skip to content
Browse files

runkit should be compiled without any warnings

  • Loading branch information...
1 parent b82db51 commit 8c73eaf748fa3702ad97841d9e4b1003a709dece @zenovich committed
Showing with 66 additions and 56 deletions.
  1. +1 −1 config.m4
  2. +4 −3 runkit.c
  3. +9 −3 runkit_functions.c
  4. +12 −15 runkit_import.c
  5. +0 −5 runkit_methods.c
  6. +24 −24 runkit_props.c
  7. +13 −4 runkit_sandbox.c
  8. +2 −0 runkit_sandbox_parent.c
  9. +1 −1 tests/Runkit_Sandbox_.active.phpt
View
2 config.m4
@@ -59,5 +59,5 @@ if test "$PHP_RUNKIT" != "no"; then
PHP_NEW_EXTENSION(runkit, runkit.c runkit_functions.c runkit_methods.c \
runkit_constants.c runkit_import.c runkit_classes.c \
runkit_sandbox.c runkit_sandbox_parent.c runkit_props.c \
-, $ext_shared,, -Wdeclaration-after-statement -Werror)
+, $ext_shared,, -Wdeclaration-after-statement -Werror -Wall)
fi
View
7 runkit.c
@@ -29,8 +29,9 @@ PHP_FUNCTION(runkit_superglobals)
{
HashPosition pos;
char *sg;
- int sg_len, type;
- long idx;
+ uint sg_len;
+ int type;
+ ulong idx;
array_init(return_value);
for(zend_hash_internal_pointer_reset_ex(CG(auto_globals), &pos);
@@ -371,7 +372,7 @@ PHP_RINIT_FUNCTION(runkit)
static int php_runkit_superglobal_dtor(void *pDest TSRMLS_DC)
{
char *sName = (char *) pDest;
- zend_hash_del(CG(auto_globals), pDest, strlen(pDest) + 1);
+ zend_hash_del(CG(auto_globals), sName, strlen(sName) + 1);
return ZEND_HASH_APPLY_REMOVE;
}
View
12 runkit_functions.c
@@ -61,7 +61,7 @@ static int php_runkit_fetch_function(int fname_type, const char *fname, int fnam
fname_lower = estrndup(fname, fname_len);
if (fname_lower == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Not enough memory", fname);
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Not enough memory");
return FAILURE;
}
PHP_RUNKIT_STRTOLOWER(fname_lower);
@@ -156,7 +156,9 @@ void php_runkit_function_copy_ctor(zend_function *fe, const char *newname, int n
if (fe->op_array.static_variables) {
HashTable *static_variables = fe->op_array.static_variables;
+#if !((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION >= 6))
zval *tmpZval;
+#endif
ALLOC_HASHTABLE(fe->op_array.static_variables);
zend_hash_init(fe->op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0);
@@ -227,7 +229,7 @@ void php_runkit_function_copy_ctor(zend_function *fe, const char *newname, int n
i = fe->op_array.last_literal;
literals = safe_emalloc(fe->op_array.last_literal, sizeof(zend_literal), 0);
while (i > 0) {
- zval *tmpZval, *oldConst;
+ zval *tmpZval;
int k;
i--;
@@ -341,9 +343,12 @@ int php_runkit_destroy_misplaced_functions(void *pDest TSRMLS_DC)
int php_runkit_restore_internal_functions(RUNKIT_53_TSRMLS_ARG(void *pDest), int num_args, va_list args, zend_hash_key *hash_key)
{
zend_internal_function *fe = (zend_internal_function *) pDest;
+
+#ifdef ZTS
#if (RUNKIT_UNDER53)
void ***tsrm_ls = va_arg(args, void***); /* NULL when !defined(ZTS) */
#endif
+#endif
if (!hash_key->nKeyLength) {
/* Nonsense, skip it */
@@ -552,7 +557,8 @@ PHP_FUNCTION(runkit_function_redefine)
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Not enough memory");
RETURN_FALSE;
}
- php_strtolower(funcname_lower, funcname_len);
+ funcname_lower_len = funcname_len;
+ PHP_RUNKIT_STRTOLOWER(funcname_lower);
if (zend_hash_del(EG(function_table), funcname_lower, funcname_len + 1) == FAILURE) {
efree(funcname_lower);
View
27 runkit_import.c
@@ -34,8 +34,9 @@ static int php_runkit_import_functions(HashTable *function_table, long flags TSR
zend_function *fe = NULL;
char *key;
const char *new_key;
- int key_len, new_key_len, type;
- long idx;
+ uint key_len, new_key_len;
+ int type;
+ ulong idx;
zend_bool add_function = 1;
zend_bool exists = 0;
@@ -175,8 +176,8 @@ static int php_runkit_import_class_consts(zend_class_entry *dce, zend_class_entr
{
HashPosition pos;
char *key;
- int key_len;
- long idx;
+ uint key_len;
+ ulong idx;
zval **c;
zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos);
@@ -227,8 +228,8 @@ static int php_runkit_import_class_static_props(zend_class_entry *dce, zend_clas
{
HashPosition pos;
char *key;
- int key_len;
- long idx;
+ uint key_len;
+ ulong idx;
zend_property_info *property_info_ptr = NULL;
zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
@@ -255,7 +256,6 @@ static int php_runkit_import_class_static_props(zend_class_entry *dce, zend_clas
if (zend_hash_find(&dce->properties_info, key, key_len, (void **) &ex_property_info_ptr) == SUCCESS && ex_property_info_ptr) {
if (override) {
if (!(ex_property_info_ptr->flags & ZEND_ACC_STATIC)) {
- int result;
if (php_runkit_def_prop_remove_int(dce, key, key_len - 1, NULL TSRMLS_CC) != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to import %s::$%s (cannot remove old member)", dce->name, key);
goto import_st_prop_skip;
@@ -323,9 +323,9 @@ static int php_runkit_import_class_props(zend_class_entry *dce, zend_class_entry
{
HashPosition pos;
char *key;
- int key_len;
+ uint key_len;
zval **p;
- long idx;
+ ulong idx;
#if PHP_MAJOR_VERSION >= 5
zend_property_info *property_info_ptr;
@@ -394,10 +394,6 @@ static int php_runkit_import_class_props(zend_class_entry *dce, zend_class_entry
}
}
- if (Z_TYPE_PP(p) == IS_CONSTANT_ARRAY) {
- zval_update_constant_ex(p, (void*) 1, dce TSRMLS_CC);
- }
-
php_runkit_def_prop_add_int(dce, key, key_len - 1, *p, 0, NULL, 0, dce, override TSRMLS_CC);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property has invalid key name");
@@ -423,8 +419,9 @@ static int php_runkit_import_classes(HashTable *class_table, long flags TSRMLS_D
for(i = 0; i < class_count; i++) {
zend_class_entry *ce = NULL;
char *key;
- int key_len, type;
- long idx;
+ uint key_len;
+ int type;
+ ulong idx;
zend_hash_get_current_data_ex(class_table, (void**)&ce, &pos);
#ifdef ZEND_ENGINE_2
View
5 runkit_methods.c
@@ -216,9 +216,6 @@ TSRMLS_DC)
zend_class_entry *ce;
zend_function *fe;
char *fname_lower;
-#ifdef ZEND_ENGINE_2
- zend_class_entry **ze;
-#endif
if (php_runkit_fetch_class_int(classname, classname_len, &ce TSRMLS_CC) == FAILURE) {
return FAILURE;
@@ -387,7 +384,6 @@ int php_runkit_clean_children_methods(RUNKIT_53_TSRMLS_ARG(zend_class_entry *ce)
int php_runkit_clear_function_runtime_cache(void *pDest TSRMLS_DC)
{
zend_function *f = (zend_function *) pDest;
- int i;
if (pDest == NULL || f->type == ZEND_INTERNAL_FUNCTION ||
f->op_array.last_cache_slot == 0 || f->op_array.run_time_cache == NULL) {
@@ -419,7 +415,6 @@ void php_runkit_clear_all_functions_runtime_cache(TSRMLS_D)
}
for (ptr = EG(current_execute_data); ptr != NULL; ptr = ptr->prev_execute_data) {
- int i;
if (ptr->op_array == NULL || ptr->op_array->last_cache_slot == 0 || ptr->op_array->run_time_cache == NULL) {
continue;
}
View
48 runkit_props.c
@@ -34,10 +34,7 @@ int php_runkit_update_children_def_props(RUNKIT_53_TSRMLS_ARG(zend_class_entry *
int access_type = va_arg(args, int);
zend_class_entry *definer_class = va_arg(args, zend_class_entry*);
int override = va_arg(args, int);
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
- zend_property_info property_info, *property_info_ptr;
- ulong h;
-#endif
+
RUNKIT_UNDER53_TSRMLS_FETCH();
#ifdef ZEND_ENGINE_2
@@ -62,10 +59,7 @@ int php_runkit_remove_children_def_props(RUNKIT_53_TSRMLS_ARG(zend_class_entry *
char *pname = va_arg(args, char*);
int pname_len = va_arg(args, int);
zend_class_entry *definer_class = va_arg(args, zend_class_entry*);
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
- zend_property_info *property_info_ptr;
- ulong h;
-#endif
+
RUNKIT_UNDER53_TSRMLS_FETCH();
#ifdef ZEND_ENGINE_2
@@ -86,8 +80,12 @@ int php_runkit_remove_children_def_props(RUNKIT_53_TSRMLS_ARG(zend_class_entry *
int php_runkit_def_prop_add_int(zend_class_entry *ce, const char *propname, int propname_len, zval *copyval, long visibility,
const char *doc_comment, int doc_comment_len, zend_class_entry *definer_class, int override TSRMLS_DC)
{
+#if PHP_MAJOR_VERSION >= 5
int i;
+#endif
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 3
HashTable *symt;
+#endif
#if PHP_MAJOR_VERSION >= 5
zend_property_info *prop_info_ptr;
long h = zend_get_hash_value((char *) propname, propname_len + 1);
@@ -157,9 +155,13 @@ int php_runkit_def_prop_add_int(zend_class_entry *ce, const char *propname, int
return FAILURE;
}
if (visibility & ZEND_ACC_PRIVATE) {
- char *oldkey, *newkey;
- int oldkey_len, newkey_len;
+ char *newkey;
+ int newkey_len;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 3) || (PHP_MAJOR_VERSION < 5)
+ char *oldkey;
+ int oldkey_len;
zval **prop;
+#endif
zend_mangle_property_name(&newkey, &newkey_len, definer_class->name, definer_class->name_length, (char *) propname, propname_len, ce->type & ZEND_INTERNAL_CLASS);
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 3) || (PHP_MAJOR_VERSION < 5)
zend_mangle_property_name(&oldkey, &oldkey_len, ce->name, ce->name_length, (char *) propname, propname_len, ce->type & ZEND_INTERNAL_CLASS);
@@ -201,7 +203,6 @@ int php_runkit_def_prop_add_int(zend_class_entry *ce, const char *propname, int
object = (zend_object *) EG(objects_store).object_buckets[i].bucket.obj.object;
if (object->ce == ce) {
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
- int prop_count, our_element;
if (!object->properties_table) {
object->properties_table = pemalloc(sizeof(void *) * ce->default_properties_count, 0);
} else {
@@ -212,7 +213,6 @@ int php_runkit_def_prop_add_int(zend_class_entry *ce, const char *propname, int
Z_ADDREF_P(object->properties_table[ce->default_properties_count-1]);
}
#else
- int prop_count, our_element;
if (!object->properties) {
ALLOC_HASHTABLE(object->properties);
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
@@ -236,9 +236,14 @@ static int php_runkit_def_prop_add(char *classname, int classname_len, char *pro
{
zend_class_entry *ce;
zval *copyval;
- char *temp, *key = propname;
- int temp_len, key_len = propname_len;
- zend_uint i;
+ char *key = propname;
+ int key_len = propname_len;
+#ifdef ZEND_ENGINE_2
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 3)
+ char *temp;
+ int temp_len;
+#endif
+#endif
if (php_runkit_fetch_class_int(classname, classname_len, &ce TSRMLS_CC)==FAILURE) {
return FAILURE;
@@ -269,6 +274,7 @@ static int php_runkit_def_prop_add(char *classname, int classname_len, char *pro
}
#endif // (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION >= 6)
+#if PHP_MAJOR_VERSION >= 5
if (
Z_TYPE_P(copyval) == IS_CONSTANT_ARRAY
#if RUNKIT_ABOVE53
@@ -277,6 +283,7 @@ static int php_runkit_def_prop_add(char *classname, int classname_len, char *pro
) {
zval_update_constant_ex(&copyval, (void*) 1, ce TSRMLS_CC);
}
+#endif
#ifdef ZEND_ENGINE_2
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 3)
@@ -316,8 +323,6 @@ static int php_runkit_def_prop_add(char *classname, int classname_len, char *pro
/* {{{ php_runkit_def_prop_remove */
int php_runkit_def_prop_remove_int(zend_class_entry *ce, const char *propname, int propname_len, zend_class_entry *definer_class TSRMLS_DC)
{
- int i;
- long h;
#if PHP_MAJOR_VERSION == 4
/* Resolve the property's name */
if (!zend_hash_exists(&ce->default_properties, (char *) propname, propname_len + 1)) {
@@ -330,6 +335,8 @@ int php_runkit_def_prop_remove_int(zend_class_entry *ce, const char *propname, i
}
zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_remove_children_def_props, 4, ce, propname, propname_len, NULL);
#else
+ int i;
+ long h;
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
int offset;
#endif
@@ -337,7 +344,6 @@ int php_runkit_def_prop_remove_int(zend_class_entry *ce, const char *propname, i
h = zend_get_hash_value((char *) propname, propname_len + 1);
if (zend_hash_quick_find(&ce->properties_info, (char *) propname, propname_len + 1, h, (void**)&property_info_ptr) == SUCCESS) {
- int access = property_info_ptr->flags & ZEND_ACC_PPP_MASK;
if (definer_class && property_info_ptr->ce != definer_class) {
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4
char *private;
@@ -430,12 +436,6 @@ int php_runkit_def_prop_remove_int(zend_class_entry *ce, const char *propname, i
static int php_runkit_def_prop_remove(char *classname, int classname_len, char *propname, int propname_len TSRMLS_DC)
{
zend_class_entry *ce;
- char *protected=0, *private=0, *key = 0;
- int protected_len, private_len, key_len = 0;
- zval **actual_value;
- int is_private = 0;
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
-#endif
if (php_runkit_fetch_class_int(classname, classname_len, &ce TSRMLS_CC) == FAILURE) {
return FAILURE;
View
17 runkit_sandbox.c
@@ -24,6 +24,7 @@
#ifdef PHP_RUNKIT_SANDBOX
#include "SAPI.h"
+#include "php_main.h"
static zend_object_handlers php_runkit_sandbox_object_handlers;
static zend_class_entry *php_runkit_sandbox_class_entry;
@@ -101,8 +102,12 @@ int php_runkit_sandbox_array_deep_copy(RUNKIT_53_TSRMLS_ARG(zval **value), int n
*/
inline void php_runkit_sandbox_ini_override(php_runkit_sandbox_object *objval, HashTable *options TSRMLS_DC)
{
- zend_bool safe_mode, safe_mode_gid, allow_url_fopen;
- char open_basedir[MAXPATHLEN] = {0}, safe_mode_include_dir[MAXPATHLEN] = {0};
+ zend_bool allow_url_fopen;
+ char open_basedir[MAXPATHLEN] = {0};
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+ zend_bool safe_mode, safe_mode_gid;
+ char safe_mode_include_dir[MAXPATHLEN] = {0};
+#endif
zval **tmpzval;
/* Collect up parent values */
@@ -345,14 +350,15 @@ PHP_METHOD(Runkit_Sandbox,__construct)
}
/* }}} */
-
+#if RUNKIT_ABOVE53
/* {{{ php_runkit_zend_object_store_get_obj */
static zend_object_store_bucket *php_runkit_zend_object_store_get_obj(const zval *zobject TSRMLS_DC)
{
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
return &EG(objects_store).object_buckets[handle];
}
-/* }}}
+/* }}} */
+#endif
/* {{{ proto Runkit_Sandbox::__call(mixed function_name, array args)
Call User Function */
@@ -463,6 +469,7 @@ PHP_METHOD(Runkit_Sandbox,__call)
if (retval) {
PHP_RUNKIT_SANDBOX_BEGIN(objval)
+ (void)(TSRMLS_C);
zval_ptr_dtor(&retval);
PHP_RUNKIT_SANDBOX_END(objval)
}
@@ -563,6 +570,7 @@ static void php_runkit_sandbox_include_or_eval(INTERNAL_FUNCTION_PARAMETERS, int
/* Don't confuse the memory manager */
if (retval) {
PHP_RUNKIT_SANDBOX_BEGIN(objval)
+ (void)(TSRMLS_C);
zval_ptr_dtor(&retval);
PHP_RUNKIT_SANDBOX_END(objval)
}
@@ -1144,6 +1152,7 @@ static void php_runkit_sandbox_sapi_sapi_error(int type, const char *error_msg,
tsrm_set_interpreter_context(objval->parent_context);
{
TSRMLS_FETCH();
+ (void)(TSRMLS_C);
php_runkit_sandbox_original_sapi.sapi_error(type, "%s", message);
}
View
2 runkit_sandbox_parent.c
@@ -76,8 +76,10 @@ typedef struct _php_runkit_sandbox_parent_object {
static HashTable *php_runkit_sandbox_parent_resolve_symbol_table(php_runkit_sandbox_parent_object *objval TSRMLS_DC)
{
int i;
+#if (RUNKIT_ABOVE53)
HashTable *oldActiveSymbolTable, *result;
zend_execute_data *oldCurExData;
+#endif
zend_execute_data *ex = EG(current_execute_data);
#if (RUNKIT_UNDER53 == 0)
View
2 tests/Runkit_Sandbox_.active.phpt
@@ -1,7 +1,7 @@
--TEST--
Runkit_Sandbox['active'] status
--SKIPIF--
-<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_SANDBOX) print "skip";
+<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_SANDBOX) print "skip";
/* May not be available due to lack of TSRM interpreter support */
if(!function_exists("runkit_lint")) print "skip"; ?>
--FILE--

0 comments on commit 8c73eaf

Please sign in to comment.
Something went wrong with that request. Please try again.