Skip to content

Commit 8802964

Browse files
author
Sascha Schumann
committed
* fix some casts
* introduce unary_op_type - cleaner than casting data voids to function ptrs
1 parent 31da733 commit 8802964

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

Zend/zend_alloc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ ZEND_API void *_emalloc(size_t size)
114114
}
115115

116116
if (!p) {
117-
fprintf(stderr,"FATAL: emalloc(): Unable to allocate %d bytes\n", size);
117+
fprintf(stderr,"FATAL: emalloc(): Unable to allocate %ld bytes\n", (long) size);
118118
exit(1);
119119
HANDLE_UNBLOCK_INTERRUPTIONS();
120120
return (void *)p;
@@ -218,7 +218,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size)
218218
REMOVE_POINTER_FROM_LIST(p);
219219
p = (mem_header *) realloc(p,sizeof(mem_header)+size+PLATFORM_PADDING+END_ALIGNMENT(size)+END_MAGIC_SIZE);
220220
if (!p) {
221-
fprintf(stderr,"FATAL: erealloc(): Unable to allocate %d bytes\n", size);
221+
fprintf(stderr,"FATAL: erealloc(): Unable to allocate %ld bytes\n", (long) size);
222222
HANDLE_UNBLOCK_INTERRUPTIONS();
223223
zend_bailout();
224224
ADD_POINTER_TO_LIST(orig);
@@ -359,7 +359,7 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
359359
/* flush old leak */
360360
if (leak_count>0) {
361361
if (!silent && leak_count>1) {
362-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (leak_count-1));
362+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long) (leak_count-1));
363363
}
364364
leak_count=0;
365365
total_bytes=0;
@@ -384,7 +384,7 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
384384
}
385385
#if ZEND_DEBUG
386386
if (!silent && leak_count>1) {
387-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (leak_count-1));
387+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long) (leak_count-1));
388388
}
389389
if (had_leaks) {
390390
ELS_FETCH();

Zend/zend_compile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ void fetch_array_begin(znode *result, znode *varname, znode *first_dim CLS_DC);
219219
void fetch_array_dim(znode *result, znode *parent, znode *dim CLS_DC);
220220
void do_print(znode *result, znode *arg CLS_DC);
221221
void do_echo(znode *arg CLS_DC);
222-
ZEND_API void *get_unary_op(int opcode);
222+
typedef int (*unary_op_type)(zval *, zval *);
223+
ZEND_API unary_op_type get_unary_op(int opcode);
223224
ZEND_API void *get_binary_op(int opcode);
224225

225226
void do_while_cond(znode *expr, znode *close_bracket_token CLS_DC);

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ int call_user_function(HashTable *function_table, zval *object, zval *function_n
306306
zend_ptr_stack_push(&EG(argument_stack), param);
307307
}
308308

309-
zend_ptr_stack_push(&EG(argument_stack), (void *) param_count);
309+
zend_ptr_stack_push(&EG(argument_stack), (void *) (long) param_count);
310310

311311
var_uninit(retval);
312312
if (function_state.function->type == ZEND_USER_FUNCTION) {

Zend/zend_indent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void handle_whitespace(int *emit_whitespace)
3838
for (c=0; c<128; c++) {
3939
if (emit_whitespace[c]>0) {
4040
for (i=0; i<emit_whitespace[c]; i++) {
41-
zend_write(&c, 1);
41+
zend_write((char *) &c, 1);
4242
}
4343
}
4444
}

Zend/zend_opcode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,17 @@ int print_class(zend_class_entry *class_entry)
310310
return 0;
311311
}
312312

313-
ZEND_API void *get_unary_op(int opcode)
313+
ZEND_API unary_op_type get_unary_op(int opcode)
314314
{
315315
switch(opcode) {
316316
case ZEND_BW_NOT:
317-
return (void *) bitwise_not_function;
317+
return bitwise_not_function;
318318
break;
319319
case ZEND_BOOL_NOT:
320-
return (void *) boolean_not_function;
320+
return boolean_not_function;
321321
break;
322322
default:
323-
return (void *) NULL;
323+
return (unary_op_type) NULL;
324324
break;
325325
}
326326
}

0 commit comments

Comments
 (0)