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 #1786 #1787

Merged
merged 10 commits into from Jan 11, 2014
Prev Previous commit
Next Next commit
Fix bugs found by the static code analyzer
  • Loading branch information
sjinks committed Jan 11, 2014
commit 22584117160f51e9f16114236d0193680f1af448
4 changes: 2 additions & 2 deletions ext/cache/backend/apc.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, save){

zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *cached_content;
zval *prepared_content, *ttl = NULL, *is_buffering;
zval *prepared_content = NULL, *ttl = NULL, *is_buffering;
zval *last_key, *prefix, *frontend;

PHALCON_MM_GROW();
Expand Down Expand Up @@ -210,7 +210,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, save){
* Call apc_store in the PHP userland since most of the time it isn't available at
* compile time
*/
if (phalcon_is_numeric(cached_content)) {
if (!prepared_content) {
phalcon_call_func_p3_noret("apc_store", last_key, cached_content, ttl);
} else {
phalcon_call_func_p3_noret("apc_store", last_key, prepared_content, ttl);
Expand Down
4 changes: 2 additions & 2 deletions ext/cache/backend/libmemcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, save){

zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *last_key, *frontend, *memcache, *cached_content;
zval *prepared_content, *ttl, *success;
zval *prepared_content = NULL, *ttl, *success;
zval *options, *special_key, *keys = NULL, *is_buffering;

PHALCON_MM_GROW();
Expand Down Expand Up @@ -343,7 +343,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, save){
}

PHALCON_OBS_VAR(success);
if (phalcon_is_numeric(cached_content)) {
if (!prepared_content) {
phalcon_call_method_p3_ex(success, &success, memcache, "set", last_key, cached_content, ttl);
} else {
phalcon_call_method_p3_ex(success, &success, memcache, "set", last_key, prepared_content, ttl);
Expand Down
6 changes: 3 additions & 3 deletions ext/cache/backend/mongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, save){

zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *last_key, *frontend, *cached_content = NULL;
zval *prepared_content, *ttl = NULL, *collection, *timestamp;
zval *prepared_content = NULL, *ttl = NULL, *collection, *timestamp;
zval *conditions, *document, *data, *is_buffering;

PHALCON_MM_GROW();
Expand Down Expand Up @@ -361,7 +361,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, save){

if (Z_TYPE_P(document) == IS_ARRAY) {
phalcon_array_update_string(&document, SL("time"), &timestamp, PH_COPY);
if (!phalcon_is_numeric(cached_content)) {
if (prepared_content) {
phalcon_array_update_string(&document, SL("data"), &prepared_content, PH_COPY);
} else {
phalcon_array_update_string(&document, SL("data"), &cached_content, PH_COPY);
Expand All @@ -373,7 +373,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, save){
phalcon_array_update_string(&data, SL("key"), &last_key, PH_COPY);
phalcon_array_update_string(&data, SL("time"), &timestamp, PH_COPY);

if (!phalcon_is_numeric(cached_content)) {
if (prepared_content) {
phalcon_array_update_string(&data, SL("data"), &prepared_content, PH_COPY);
} else {
phalcon_array_update_string(&data, SL("data"), &cached_content, PH_COPY);
Expand Down
4 changes: 2 additions & 2 deletions ext/cache/backend/xcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Xcache, save){

zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *cached_content, *keys, *last_key, *frontend;
zval *prepared_content, *ttl, *success, *is_buffering;
zval *prepared_content = NULL, *ttl, *success, *is_buffering;
zval *prefix, *options, *special_key, *z_zero, *tmp;

PHALCON_MM_GROW();
Expand Down Expand Up @@ -238,7 +238,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Xcache, save){

PHALCON_OBS_VAR(success);

if (phalcon_is_numeric(cached_content)) {
if (!prepared_content) {
phalcon_call_func_p3_ex(success, &success, "xcache_set", last_key, cached_content, ttl);
} else {
phalcon_call_func_p3_ex(success, &success, "xcache_set", last_key, prepared_content, ttl);
Expand Down
9 changes: 5 additions & 4 deletions ext/mvc/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -3599,6 +3599,7 @@ PHP_METHOD(Phalcon_Mvc_Model, _doLowUpdate){
HashTable *ah0, *ah1;
HashPosition hp0, hp1;
zval **hd;
int i_use_dynamic_update; /* To keep static code analyzer happy */

PHALCON_MM_GROW();

Expand Down Expand Up @@ -3626,13 +3627,13 @@ PHP_METHOD(Phalcon_Mvc_Model, _doLowUpdate){
*/
PHALCON_INIT_VAR(use_dynamic_update);
phalcon_call_method_p1(use_dynamic_update, manager, "isusingdynamicupdate", this_ptr);
if (zend_is_true(use_dynamic_update)) {
i_use_dynamic_update = zend_is_true(use_dynamic_update);
if (i_use_dynamic_update) {

PHALCON_OBS_VAR(snapshot);
phalcon_read_property_this(&snapshot, this_ptr, SL("_snapshot"), PH_NOISY_CC);
if (Z_TYPE_P(snapshot) != IS_ARRAY) {
PHALCON_INIT_NVAR(use_dynamic_update);
ZVAL_BOOL(use_dynamic_update, 0);
i_use_dynamic_update = 0;
}
}

Expand Down Expand Up @@ -3704,7 +3705,7 @@ PHP_METHOD(Phalcon_Mvc_Model, _doLowUpdate){
/**
* When dynamic update is not used we pass every field to the update
*/
if (!zend_is_true(use_dynamic_update)) {
if (!i_use_dynamic_update) {
phalcon_array_append(&fields, field, PH_SEPARATE);
phalcon_array_append(&values, value, PH_SEPARATE);

Expand Down