Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings #1169

Merged
merged 13 commits into from Aug 29, 2013
Merged
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: php
language:
- php
- c

php:
- 5.3
Expand All @@ -19,7 +21,7 @@ before_script:
- (cd php-tests/library/Mustache; git checkout master)
- (cd php-tests/library/Twig; git checkout master)
- (cd unit-tests/engines/; git clone -q git://github.com/bobthecow/mustache.php.git & git clone -q git://github.com/fabpot/Twig.git & wait)
- (cd ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall"; phpize && ./configure --enable-phalcon && make --silent -j4 && sudo make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini)
- (cd ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -Werror -Wno-error=uninitialized"; phpize && ./configure --silent --enable-phalcon && make --silent -j4 > /dev/null && sudo make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini)
- ulimit -c unlimited || true

script:
Expand Down
1 change: 1 addition & 0 deletions ext/db/dialect/oracle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ PHP_METHOD(Phalcon_Db_Dialect_Oracle, select){
PHALCON_CPY_WRT(tables_sql, tables);
}

PHALCON_INIT_VAR(sql);
if (phalcon_array_isset_string_fetch(&distinct, definition, SS("definition"))) {
assert(Z_TYPE_P(distinct) == IS_LONG);
if (Z_LVAL_P(distinct) == 0) {
Expand Down
1 change: 1 addition & 0 deletions ext/forms/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "kernel/operators.h"
#include "kernel/concat.h"
#include "kernel/file.h"
#include "kernel/hash.h"

/**
* Phalcon\Forms\Element
Expand Down
8 changes: 4 additions & 4 deletions ext/image/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ PHP_METHOD(Phalcon_Image_Adapter, resize){

zval *width = NULL, *height = NULL, *zmaster = NULL;
zval *image_width, *image_height;
int tmp_image_width, tmp_image_height, tmp_width, tmp_height, master;
int tmp_image_width, tmp_image_height, tmp_width = 0, tmp_height = 0, master;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -809,15 +809,15 @@ PHP_METHOD(Phalcon_Image_Adapter, text){
Z_TYPE(tmp) = IS_STRING;
ZVAL_STRINGL(&tmp, Z_STRVAL_P(tmp_color), 2, 0);

PHALCON_INIT_NVAR(r);
PHALCON_INIT_VAR(r);
_php_math_basetozval(&tmp, 16, r);

Z_STRVAL(tmp) += 2;
PHALCON_INIT_NVAR(g);
PHALCON_INIT_VAR(g);
_php_math_basetozval(&tmp, 16, g);

Z_STRVAL(tmp) += 2;
PHALCON_INIT_NVAR(b);
PHALCON_INIT_VAR(b);
_php_math_basetozval(&tmp, 16, b);

PHALCON_CALL_METHOD(NULL, NULL, this_ptr, "_text", 0, 9, text, offset_x, offset_y, opacity, r, g, b, size, fontfile);
Expand Down
2 changes: 1 addition & 1 deletion ext/image/adapter/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ PHP_METHOD(Phalcon_Image_Adapter_GD, _watermark) {
phalcon_call_func_p6_noret("imagefilledrectangle", overlay, tmp, tmp, width, height, color);
}

PHALCON_INIT_NVAR(blendmode);
PHALCON_INIT_VAR(blendmode);
ZVAL_LONG(blendmode, 1);
phalcon_call_func_p2_noret("imagealphablending", image, blendmode);

Expand Down
12 changes: 12 additions & 0 deletions ext/kernel/fcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ static int phalcon_call_user_function(HashTable *function_table, zval **object_p
}
}
}
else {
params_ptr = NULL;
}

fci.size = sizeof(fci);
fci.function_table = function_table;
Expand Down Expand Up @@ -188,6 +191,9 @@ static int phalcon_call_func_vparams(zval *return_value, zval **return_value_ptr
params[i] = va_arg(ap, zval*);
}
}
else {
params_ptr = NULL;
}

status = phalcon_call_user_function(EG(function_table), NULL, func, return_value, return_value_ptr, param_count, params_ptr TSRMLS_CC);

Expand Down Expand Up @@ -248,6 +254,9 @@ int phalcon_call_method_vparams(zval *return_value, zval **return_value_ptr, zva
params[i] = va_arg(ap, zval*);
}
}
else {
params_ptr = NULL;
}

ce = Z_OBJCE_P(object);
active_scope = EG(scope);
Expand Down Expand Up @@ -317,6 +326,9 @@ static int phalcon_call_static_zval_str_func_vparams(zval *return_value, zval **
params[i] = va_arg(ap, zval*);
}
}
else {
params_ptr = NULL;
}

status = phalcon_call_user_function(EG(function_table), NULL, fn, return_value, return_value_ptr, param_count, params_ptr TSRMLS_CC);

Expand Down
5 changes: 3 additions & 2 deletions ext/kernel/framework/router.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ zval *phalcon_replace_marker(int named, zval *paths, zval *replacements, unsigne

zval **zv, **tmp;
int result = FAILURE;
unsigned int length, variable_length, ch;
unsigned int length = 0, variable_length, ch;
char *item = NULL, *cursor_var, *variable = NULL;
int not_valid = 0, j;

Expand Down Expand Up @@ -272,7 +272,7 @@ void phalcon_extract_named_params(zval *return_value, zval *str, zval *matches){
unsigned int intermediate = 0, length, number_matches = 0, found_pattern;
int variable_length, regexp_length = 0, not_valid = 0;
char *cursor, *cursor_var, *marker = NULL;
char *item, *variable = NULL, *regexp;
char *item, *variable = NULL, *regexp = NULL;
smart_str route_str = {0};

if (Z_TYPE_P(str) != IS_STRING) {
Expand Down Expand Up @@ -351,6 +351,7 @@ void phalcon_extract_named_params(zval *return_value, zval *str, zval *matches){

if (variable) {
if (regexp_length > 0) {
ASSUME(regexp != NULL);

/**
* Check if we need to add parentheses to the expression
Expand Down
3 changes: 3 additions & 0 deletions ext/kernel/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@ int phalcon_create_instance_params(zval *return_value, const zval *class_name, z
params_ptr[i] = *item;
}
}
else {
params_ptr = NULL;
}

outcome = phalcon_call_method_params(NULL, NULL, return_value, SL("__construct"), zend_inline_hash_func(SS("__construct")) TSRMLS_CC, -param_count, params_ptr);

Expand Down
27 changes: 12 additions & 15 deletions ext/kernel/operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,29 +248,26 @@ void phalcon_cast(zval *result, zval *var, zend_uint type){
*/
long phalcon_get_intval(const zval *op) {

int type;
long long_value;
double double_value;

switch (Z_TYPE_P(op)) {
case IS_LONG:
return Z_LVAL_P(op);
case IS_BOOL:
return Z_BVAL_P(op);
case IS_DOUBLE:
return (long) Z_DVAL_P(op);
case IS_STRING:
if ((type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &long_value, &double_value, 0))) {
if (type == IS_LONG) {
return long_value;
} else {
if (type == IS_DOUBLE) {
return double_value;
} else {
return 0;
}
}
case IS_STRING: {
long long_value;
double double_value;
ASSUME(Z_STRVAL_P(op) != NULL);
zend_uchar type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &long_value, &double_value, 0);
if (type == IS_LONG) {
return long_value;
}
if (type == IS_DOUBLE) {
return (long)double_value;
}
return 0;
}
}

return 0;
Expand Down