marked char pointer arguments as const in lots of

places where strings pointed to are not modified 
to prevent compiler warnings about discarded qualifiers ...
This commit is contained in:
Hartmut Holzgraefe 2010-10-14 21:33:10 +00:00
parent 738be1a003
commit aaa2f1c30b
17 changed files with 64 additions and 63 deletions

View File

@ -461,7 +461,7 @@ typedef struct _zend_trait_alias zend_trait_alias;
struct _zend_class_entry {
char type;
char *name;
const char *name;
zend_uint name_length;
struct _zend_class_entry *parent;
int refcount;

View File

@ -248,7 +248,7 @@ ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC) /
/* }}} */
/* 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 int parse_arg_object_to_string(zval **arg, char **p, int *pl, int type TS
}
/* }}} */
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 char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
}
/* }}} */
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_arg(int arg_num, zval **arg, va_list *va, char **spec, int
}
/* }}} */
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 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
}\
}
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_ex(int flags, int num_args TSRMLS_DC, char *t
}
/* }}} */
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_parameters(int num_args TSRMLS_DC, char *type_spec, ...)
}
/* }}} */
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(int num_args TSRMLS_DC, zval *this_ptr
}
/* }}} */
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_API int zend_register_functions(zend_class_entry *scope, const zend_functio
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 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
{
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;

View File

@ -166,7 +166,7 @@ typedef struct _zend_fcall_info_cache {
#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 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array TS
/* 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_property(zend_class_entry *scope, zval *object, char *n
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)

View File

@ -1973,7 +1973,7 @@ ZEND_FUNCTION(debug_print_backtrace)
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 @@ ZEND_FUNCTION(debug_print_backtrace)
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;

View File

@ -281,7 +281,7 @@ ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result,
{
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 @@ ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result,
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 @@ ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result,
/* 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;

View File

@ -594,7 +594,7 @@ static inline int zend_verify_arg_error(const zend_function *zf, zend_uint arg_n
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 = "::";

View File

@ -147,11 +147,11 @@ ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */
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);

View File

@ -106,7 +106,7 @@ ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int r
}
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(void (*ld)(void *), void (*pld)(void
}
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 @@ void zend_destroy_rsrc_list_dtors(void)
}
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;

View File

@ -48,7 +48,7 @@ typedef struct _zend_rsrc_list_dtors_entry {
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 @@ typedef struct _zend_rsrc_list_dtors_entry {
#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 @@ ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC);
#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 */

View File

@ -98,7 +98,7 @@ struct _zend_module_entry {
unsigned char type;
void *handle;
int module_number;
char *build_id;
const char *build_id;
};
#define MODULE_DEP_REQUIRED 1

View File

@ -402,7 +402,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
}
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);
}

View File

@ -167,7 +167,7 @@ check_digits:
}
} 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 @@ process_double:
/* 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 @@ zend_memnstr(char *haystack, char *needle, int needle_len, char *end)
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;
}
}

View File

@ -120,7 +120,7 @@ ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSR
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));

View File

@ -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 @@ void zend_interned_strings_dtor(TSRMLS_D)
#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 @@ static char *zend_new_interned_string_int(char *arKey, int nKeyLength, int free_
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 @@ static char *zend_new_interned_string_int(char *arKey, int nKeyLength, int free_
p->arKey = (char*)(p+1);
memcpy(p->arKey, arKey, nKeyLength);
if (free_src) {
efree(arKey);
efree((void *)arKey);
}
p->nKeyLength = nKeyLength;
p->h = h;

View File

@ -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);

View File

@ -2030,7 +2030,7 @@ ret1:
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 @@ retfree:
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 @@ ret:
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 @@ ZEND_API double zend_hex_strtod(const char *str, char **endptr)
}
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 @@ ZEND_API double zend_oct_strtod(const char *str, char **endptr)
}
if (endptr != NULL) {
*endptr = (char *)(any ? s - 1 : str);
*endptr = any ? s - 1 : str;
}
return value;

View File

@ -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()