hholzgra Thu, 14 Oct 2010 21:33:10 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=304407
Log: marked char pointer arguments as const in lots of places where strings pointed to are not modified to prevent compiler warnings about discarded qualifiers ... Changed paths: U php/php-src/trunk/Zend/zend.h U php/php-src/trunk/Zend/zend_API.c U php/php-src/trunk/Zend/zend_API.h U php/php-src/trunk/Zend/zend_builtin_functions.c U php/php-src/trunk/Zend/zend_constants.c U php/php-src/trunk/Zend/zend_execute.c U php/php-src/trunk/Zend/zend_ini.c U php/php-src/trunk/Zend/zend_list.c U php/php-src/trunk/Zend/zend_list.h U php/php-src/trunk/Zend/zend_modules.h U php/php-src/trunk/Zend/zend_opcode.c U php/php-src/trunk/Zend/zend_operators.h U php/php-src/trunk/Zend/zend_stream.c U php/php-src/trunk/Zend/zend_string.c U php/php-src/trunk/Zend/zend_string.h U php/php-src/trunk/Zend/zend_strtod.c U php/php-src/trunk/Zend/zend_strtod.h
Modified: php/php-src/trunk/Zend/zend.h =================================================================== --- php/php-src/trunk/Zend/zend.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -461,7 +461,7 @@ struct _zend_class_entry { char type; - char *name; + const char *name; zend_uint name_length; struct _zend_class_entry *parent; int refcount; Modified: php/php-src/trunk/Zend/zend_API.c =================================================================== --- php/php-src/trunk/Zend/zend_API.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_API.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -248,7 +248,7 @@ /* }}} */ /* returns 1 if you need to copy result, 0 if it's already a copy */ -ZEND_API int zend_get_object_classname(const zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC) /* {{{ */ +ZEND_API int zend_get_object_classname(const zval *object, const char **class_name, zend_uint *class_name_len TSRMLS_DC) /* {{{ */ { if (Z_OBJ_HT_P(object)->get_class_name == NULL || Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) { @@ -302,9 +302,9 @@ } /* }}} */ -static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */ +static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, const char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */ { - char *spec_walk = *spec; + const char *spec_walk = *spec; char c = *spec_walk++; int return_null = 0; @@ -659,7 +659,7 @@ } /* }}} */ -static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet TSRMLS_DC) /* {{{ */ +static int zend_parse_arg(int arg_num, zval **arg, va_list *va, const char **spec, int quiet TSRMLS_DC) /* {{{ */ { char *expected_type = NULL, *error = NULL; int severity = E_WARNING; @@ -689,9 +689,9 @@ } /* }}} */ -static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int flags TSRMLS_DC) /* {{{ */ +static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, int flags TSRMLS_DC) /* {{{ */ { - char *spec_walk; + const char *spec_walk; int c, i; int min_num_args = -1; int max_num_args = 0; @@ -861,7 +861,7 @@ }\ } -ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...) /* {{{ */ +ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, const char *type_spec, ...) /* {{{ */ { va_list va; int retval; @@ -876,7 +876,7 @@ } /* }}} */ -ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...) /* {{{ */ +ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, const char *type_spec, ...) /* {{{ */ { va_list va; int retval; @@ -891,11 +891,11 @@ } /* }}} */ -ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...) /* {{{ */ +ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; int retval; - char *p = type_spec; + const char *p = type_spec; zval **object; zend_class_entry *ce; @@ -927,11 +927,11 @@ } /* }}} */ -ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...) /* {{{ */ +ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; int retval; - char *p = type_spec; + const char *p = type_spec; zval **object; zend_class_entry *ce; int quiet = flags & ZEND_PARSE_PARAMS_QUIET; @@ -1922,7 +1922,7 @@ zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL; char *lowercase_name; int fname_len; - char *lc_class_name = NULL; + const char *lc_class_name = NULL; int class_name_len = 0; if (type==MODULE_PERSISTENT) { @@ -2594,7 +2594,8 @@ { zend_class_entry *ce_org = fcc->calling_scope; int retval = 0; - char *mname, *lmname, *colon; + char *mname, *lmname; + const char *colon; int clen, mlen; zend_class_entry *last_scope; HashTable *ftable; Modified: php/php-src/trunk/Zend/zend_API.h =================================================================== --- php/php-src/trunk/Zend/zend_API.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_API.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -166,7 +166,7 @@ #define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ { \ - char *cl_name = class_name; \ + const char *cl_name = class_name; \ int _len = class_name_len; \ class_container.name = zend_new_interned_string(cl_name, _len+1, 0 TSRMLS_CC); \ if (class_container.name == cl_name) { \ @@ -244,12 +244,12 @@ /* Parameter parsing API -- andrei */ #define ZEND_PARSE_PARAMS_QUIET 1<<1 -ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...); -ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...); +ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, const char *type_spec, ...); +ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, const char *type_spec, ...); ZEND_API char *zend_zval_type_name(const zval *arg); -ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...); -ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...); +ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...); +ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...); /* End of parameter parsing API -- andrei */ @@ -331,7 +331,7 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC); ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC); -ZEND_API int zend_get_object_classname(const zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC); +ZEND_API int zend_get_object_classname(const zval *object, const char **class_name, zend_uint *class_name_len TSRMLS_DC); ZEND_API char *zend_get_type_by_const(int type); #define getThis() (this_ptr) Modified: php/php-src/trunk/Zend/zend_builtin_functions.c =================================================================== --- php/php-src/trunk/Zend/zend_builtin_functions.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_builtin_functions.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -1973,7 +1973,7 @@ int lineno; char *function_name; char *filename; - char *class_name = NULL; + const char *class_name = NULL; char *call_type; char *include_filename = NULL; zval *arg_array = NULL; @@ -1989,7 +1989,7 @@ ptr = ptr->prev_execute_data; while (ptr) { - char *free_class_name = NULL; + const char *free_class_name = NULL; class_name = call_type = NULL; arg_array = NULL; Modified: php/php-src/trunk/Zend/zend_constants.c =================================================================== --- php/php-src/trunk/Zend/zend_constants.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_constants.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -281,7 +281,7 @@ { zend_constant *c; int retval = 1; - char *colon; + const char *colon; zend_class_entry *ce = NULL; char *class_name; zval **ret_constant; @@ -297,7 +297,7 @@ colon > name && (*(colon - 1) == ':')) { int class_name_len = colon - name - 1; int const_name_len = name_len - class_name_len - 2; - char *constant_name = colon + 1; + const char *constant_name = colon + 1; char *lcname; class_name = estrndup(name, class_name_len); @@ -360,7 +360,7 @@ /* compound constant name */ int prefix_len = colon - name; int const_name_len = name_len - prefix_len - 1; - char *constant_name = colon + 1; + const char *constant_name = colon + 1; char *lcname; int found_const = 0; Modified: php/php-src/trunk/Zend/zend_execute.c =================================================================== --- php/php-src/trunk/Zend/zend_execute.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_execute.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -594,7 +594,7 @@ zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data; char *fname = zf->common.function_name; char *fsep; - char *fclass; + const char *fclass; if (zf->common.scope) { fsep = "::"; Modified: php/php-src/trunk/Zend/zend_ini.c =================================================================== --- php/php-src/trunk/Zend/zend_ini.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_ini.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -147,11 +147,11 @@ static int ini_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */ { - Bucket *f; - Bucket *s; + const Bucket *f; + const Bucket *s; - f = *((Bucket **) a); - s = *((Bucket **) b); + f = *((const Bucket **) a); + s = *((const Bucket **) b); if (f->nKeyLength == 0 && s->nKeyLength == 0) { /* both numeric */ return ZEND_NORMALIZE_BOOL(f->nKeyLength - s->nKeyLength); Modified: php/php-src/trunk/Zend/zend_list.c =================================================================== --- php/php-src/trunk/Zend/zend_list.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_list.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -106,7 +106,7 @@ } -ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...) +ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...) { int id; int actual_resource_type; @@ -289,7 +289,7 @@ } -ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number) +ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number) { zend_rsrc_list_dtors_entry lde; @@ -348,7 +348,7 @@ } -char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC) +const char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC) { zend_rsrc_list_dtors_entry *lde; int rsrc_type; Modified: php/php-src/trunk/Zend/zend_list.h =================================================================== --- php/php-src/trunk/Zend/zend_list.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_list.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -48,7 +48,7 @@ rsrc_dtor_func_t list_dtor_ex; rsrc_dtor_func_t plist_dtor_ex; - char *type_name; + const char *type_name; int module_number; int resource_id; @@ -58,7 +58,7 @@ #define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number); ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number); -ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number); +ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number); void list_entry_destructor(void *ptr); void plist_entry_destructor(void *ptr); @@ -80,9 +80,9 @@ #define zend_list_find(id, type) _zend_list_find(id, type TSRMLS_CC) ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type TSRMLS_DC); -ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...); +ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...); -ZEND_API char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC); +ZEND_API const char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC); ZEND_API int zend_fetch_list_dtor_id(char *type_name); extern ZEND_API int le_index_ptr; /* list entry type for index pointers */ Modified: php/php-src/trunk/Zend/zend_modules.h =================================================================== --- php/php-src/trunk/Zend/zend_modules.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_modules.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -98,7 +98,7 @@ unsigned char type; void *handle; int module_number; - char *build_id; + const char *build_id; }; #define MODULE_DEP_REQUIRED 1 Modified: php/php-src/trunk/Zend/zend_opcode.c =================================================================== --- php/php-src/trunk/Zend/zend_opcode.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_opcode.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -402,7 +402,7 @@ } if (op_array->arg_info) { for (i=0; i<op_array->num_args; i++) { - str_efree((char*)op_array->arg_info[i].name); + str_efree((char *)op_array->arg_info[i].name); if (op_array->arg_info[i].class_name && !IS_INTERNED(op_array->arg_info[i].class_name)) { efree((char*)op_array->arg_info[i].class_name); } Modified: php/php-src/trunk/Zend/zend_operators.h =================================================================== --- php/php-src/trunk/Zend/zend_operators.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_operators.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -167,7 +167,7 @@ } } else if (!(digits < SIZEOF_LONG * 2 || (digits == SIZEOF_LONG * 2 && ptr[-digits] <= '7'))) { if (dval) { - local_dval = zend_hex_strtod(str, (char **)&ptr); + local_dval = zend_hex_strtod(str, &ptr); } type = IS_DOUBLE; } @@ -178,7 +178,7 @@ /* If there's a dval, do the conversion; else continue checking * the digits if we need to check for a full match */ if (dval) { - local_dval = zend_strtod(str, (char **)&ptr); + local_dval = zend_strtod(str, &ptr); } else if (allow_errors != 1 && dp_or_e != -1) { dp_or_e = (*ptr++ == '.') ? 1 : 2; goto check_digits; @@ -256,17 +256,17 @@ return NULL; } -static inline void *zend_memrchr(const void *s, int c, size_t n) +static inline const void *zend_memrchr(const void *s, int c, size_t n) { - register unsigned char *e; + register const unsigned char *e; if (n <= 0) { return NULL; } - for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) { - if (*e == (unsigned char)c) { - return (void *)e; + for (e = (const unsigned char *)s + n - 1; e >= (const unsigned char *)s; e--) { + if (*e == (const unsigned char)c) { + return (const void *)e; } } Modified: php/php-src/trunk/Zend/zend_stream.c =================================================================== --- php/php-src/trunk/Zend/zend_stream.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_stream.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -120,7 +120,7 @@ handle->type = ZEND_HANDLE_FP; handle->opened_path = NULL; handle->handle.fp = zend_fopen(filename, &handle->opened_path TSRMLS_CC); - handle->filename = (char *)filename; + handle->filename = filename; handle->free_filename = 0; memset(&handle->handle.stream.mmap, 0, sizeof(zend_mmap)); Modified: php/php-src/trunk/Zend/zend_string.c =================================================================== --- php/php-src/trunk/Zend/zend_string.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_string.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -29,11 +29,11 @@ # include <sys/mman.h> #endif -ZEND_API char *(*zend_new_interned_string)(char *str, int len, int free_src TSRMLS_DC); +ZEND_API const char *(*zend_new_interned_string)(const char *str, int len, int free_src TSRMLS_DC); ZEND_API void (*zend_interned_strings_snapshot)(TSRMLS_D); ZEND_API void (*zend_interned_strings_restore)(TSRMLS_D); -static char *zend_new_interned_string_int(char *str, int len, int free_src TSRMLS_DC); +static const char *zend_new_interned_string_int(const char *str, int len, int free_src TSRMLS_DC); static void zend_interned_strings_snapshot_int(TSRMLS_D); static void zend_interned_strings_restore_int(TSRMLS_D); @@ -79,7 +79,7 @@ #endif } -static char *zend_new_interned_string_int(char *arKey, int nKeyLength, int free_src TSRMLS_DC) +static const char *zend_new_interned_string_int(const char *arKey, int nKeyLength, int free_src TSRMLS_DC) { #ifndef ZTS ulong h; @@ -97,7 +97,7 @@ if ((p->h == h) && (p->nKeyLength == nKeyLength)) { if (!memcmp(p->arKey, arKey, nKeyLength)) { if (free_src) { - efree(arKey); + efree((void *)arKey); } return p->arKey; } @@ -121,7 +121,7 @@ p->arKey = (char*)(p+1); memcpy(p->arKey, arKey, nKeyLength); if (free_src) { - efree(arKey); + efree((void *)arKey); } p->nKeyLength = nKeyLength; p->h = h; Modified: php/php-src/trunk/Zend/zend_string.h =================================================================== --- php/php-src/trunk/Zend/zend_string.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_string.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -23,7 +23,7 @@ #include "zend.h" -ZEND_API extern char *(*zend_new_interned_string)(char *str, int len, int free_src TSRMLS_DC); +ZEND_API extern const char *(*zend_new_interned_string)(const char *str, int len, int free_src TSRMLS_DC); ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D); ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D); Modified: php/php-src/trunk/Zend/zend_strtod.c =================================================================== --- php/php-src/trunk/Zend/zend_strtod.c 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_strtod.c 2010-10-14 21:33:10 UTC (rev 304407) @@ -2030,7 +2030,7 @@ return s0; } -ZEND_API double zend_strtod (CONST char *s00, char **se) +ZEND_API double zend_strtod (CONST char *s00, CONST char **se) { int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; @@ -2563,7 +2563,7 @@ Bfree(delta); ret: if (se) - *se = (char *)s; + *se = s; result = sign ? -value(rv) : value(rv); _THREAD_PRIVATE_MUTEX_LOCK(pow5mult_mutex); @@ -2577,7 +2577,7 @@ return result; } -ZEND_API double zend_hex_strtod(const char *str, char **endptr) +ZEND_API double zend_hex_strtod(const char *str, const char **endptr) { const char *s = str; char c; @@ -2604,13 +2604,13 @@ } if (endptr != NULL) { - *endptr = (char *)(any ? s - 1 : str); + *endptr = any ? s - 1 : str; } return value; } -ZEND_API double zend_oct_strtod(const char *str, char **endptr) +ZEND_API double zend_oct_strtod(const char *str, const char **endptr) { const char *s = str; char c; @@ -2632,7 +2632,7 @@ } if (endptr != NULL) { - *endptr = (char *)(any ? s - 1 : str); + *endptr = any ? s - 1 : str; } return value; Modified: php/php-src/trunk/Zend/zend_strtod.h =================================================================== --- php/php-src/trunk/Zend/zend_strtod.h 2010-10-14 19:58:54 UTC (rev 304406) +++ php/php-src/trunk/Zend/zend_strtod.h 2010-10-14 21:33:10 UTC (rev 304407) @@ -27,9 +27,9 @@ BEGIN_EXTERN_C() ZEND_API void zend_freedtoa(char *s); ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sign, char **rve); -ZEND_API double zend_strtod(const char *s00, char **se); -ZEND_API double zend_hex_strtod(const char *str, char **endptr); -ZEND_API double zend_oct_strtod(const char *str, char **endptr); +ZEND_API double zend_strtod(const char *s00, const char **se); +ZEND_API double zend_hex_strtod(const char *str, const char **endptr); +ZEND_API double zend_oct_strtod(const char *str, const char **endptr); ZEND_API int zend_startup_strtod(void); ZEND_API int zend_shutdown_strtod(void); END_EXTERN_C()
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php