Skip to content

Commit 9eb9048

Browse files
Merge branch 'issue.1054' into develop
2 parents f1d914e + 2b91d58 commit 9eb9048

File tree

6 files changed

+46
-21
lines changed

6 files changed

+46
-21
lines changed

cluster_library.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ PHP_REDIS_API void cluster_sub_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *
16781678
/* Multibulk response, {[pattern], type, channel, payload} */
16791679
while(1) {
16801680
/* Arguments */
1681-
zval *z_type, *z_chan, *z_pat, *z_data;
1681+
zval *z_type, *z_chan, *z_pat = NULL, *z_data;
16821682
int tab_idx=1, is_pmsg;
16831683

16841684
// Get the next subscribe response
@@ -2358,9 +2358,9 @@ int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result,
23582358
int mbulk_resp_loop_zipstr(RedisSock *redis_sock, zval *z_result,
23592359
long long count, void *ctx TSRMLS_DC)
23602360
{
2361-
char *line, *key;
2362-
int line_len, key_len;
2363-
long long idx=0;
2361+
char *line, *key = NULL;
2362+
int line_len, key_len = 0;
2363+
long long idx = 0;
23642364

23652365
// Our count wil need to be divisible by 2
23662366
if(count % 2 != 0) {
@@ -2401,9 +2401,9 @@ int mbulk_resp_loop_zipstr(RedisSock *redis_sock, zval *z_result,
24012401
int mbulk_resp_loop_zipdbl(RedisSock *redis_sock, zval *z_result,
24022402
long long count, void *ctx TSRMLS_DC)
24032403
{
2404-
char *line, *key;
2405-
int line_len, key_len;
2406-
long long idx=0;
2404+
char *line, *key = NULL;
2405+
int line_len, key_len = 0;
2406+
long long idx = 0;
24072407

24082408
// Our context will need to be divisible by 2
24092409
if(count %2 != 0) {

common.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef REDIS_COMMON_H
55
#define REDIS_COMMON_H
66

7+
#define PHPREDIS_NOTUSED(v) ((void)v)
8+
79
#include <ext/standard/php_var.h>
810
#include <ext/standard/php_math.h>
911
#if (PHP_MAJOR_VERSION < 7)
@@ -20,6 +22,7 @@ typedef struct {
2022
char *val;
2123
} zend_string;
2224

25+
2326
#define zend_string_release(s) do { \
2427
if ((s) && (s)->gc) { \
2528
if ((s)->gc & 0x10 && (s)->val) efree((s)->val); \
@@ -201,9 +204,9 @@ inline_zend_get_parameters_array(int ht, int param_count, zval *argument_array T
201204

202205
typedef zend_rsrc_list_entry zend_resource;
203206

204-
static int (*_add_next_index_string)(zval *, const char *, int) = &add_next_index_string;
207+
extern int (*_add_next_index_string)(zval *, const char *, int);
205208
#define add_next_index_string(arg, str) _add_next_index_string(arg, str, 1);
206-
static int (*_add_next_index_stringl)(zval *, const char *, uint, int) = &add_next_index_stringl;
209+
extern int (*_add_next_index_stringl)(zval *, const char *, uint, int);
207210
#define add_next_index_stringl(arg, str, length) _add_next_index_stringl(arg, str, length, 1);
208211

209212
#undef ZVAL_STRING
@@ -252,30 +255,30 @@ inline_call_user_function(HashTable *function_table, zval *object, zval *functio
252255

253256
#undef add_assoc_bool
254257
#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b)
255-
static int (*_add_assoc_bool_ex)(zval *, const char *, uint, int) = &add_assoc_bool_ex;
258+
extern int (*_add_assoc_bool_ex)(zval *, const char *, uint, int);
256259
#define add_assoc_bool_ex(_arg, _key, _key_len, _b) _add_assoc_bool_ex(_arg, _key, _key_len + 1, _b)
257260

258261
#undef add_assoc_long
259262
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
260-
static int (*_add_assoc_long_ex)(zval *, const char *, uint, long) = &add_assoc_long_ex;
263+
extern int (*_add_assoc_long_ex)(zval *, const char *, uint, long);
261264
#define add_assoc_long_ex(_arg, _key, _key_len, _n) _add_assoc_long_ex(_arg, _key, _key_len + 1, _n)
262265

263266
#undef add_assoc_double
264267
#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key), __d)
265-
static int (*_add_assoc_double_ex)(zval *, const char *, uint, double) = &add_assoc_double_ex;
268+
extern int (*_add_assoc_double_ex)(zval *, const char *, uint, double);
266269
#define add_assoc_double_ex(_arg, _key, _key_len, _d) _add_assoc_double_ex(_arg, _key, _key_len + 1, _d)
267270

268271
#undef add_assoc_string
269272
#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
270-
static int (*_add_assoc_string_ex)(zval *, const char *, uint, char *, int) = &add_assoc_string_ex;
273+
extern int (*_add_assoc_string_ex)(zval *, const char *, uint, char *, int);
271274
#define add_assoc_string_ex(_arg, _key, _key_len, _str) _add_assoc_string_ex(_arg, _key, _key_len + 1, _str, 1)
272275

273-
static int (*_add_assoc_stringl_ex)(zval *, const char *, uint, char *, uint, int) = &add_assoc_stringl_ex;
276+
extern int (*_add_assoc_stringl_ex)(zval *, const char *, uint, char *, uint, int);
274277
#define add_assoc_stringl_ex(_arg, _key, _key_len, _str, _length) _add_assoc_stringl_ex(_arg, _key, _key_len + 1, _str, _length, 1)
275278

276279
#undef add_assoc_zval
277280
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
278-
static int (*_add_assoc_zval_ex)(zval *, const char *, uint, zval *) = &add_assoc_zval_ex;
281+
extern int (*_add_assoc_zval_ex)(zval *, const char *, uint, zval *);
279282
#define add_assoc_zval_ex(_arg, _key, _key_len, _value) _add_assoc_zval_ex(_arg, _key, _key_len + 1, _value);
280283

281284
typedef long zend_long;
@@ -355,9 +358,9 @@ zval_get_string(zval *op)
355358
return zstr;
356359
}
357360

358-
static void (*_php_var_serialize)(smart_str *, zval **, php_serialize_data_t * TSRMLS_DC) = &php_var_serialize;
361+
extern void (*_php_var_serialize)(smart_str *, zval **, php_serialize_data_t * TSRMLS_DC);
359362
#define php_var_serialize(buf, struc, data) _php_var_serialize(buf, &struc, data TSRMLS_CC)
360-
static int (*_php_var_unserialize)(zval **, const unsigned char **, const unsigned char *, php_unserialize_data_t * TSRMLS_DC) = &php_var_unserialize;
363+
extern int (*_php_var_unserialize)(zval **, const unsigned char **, const unsigned char *, php_unserialize_data_t * TSRMLS_DC);
361364
#define php_var_unserialize(rval, p, max, var_hash) _php_var_unserialize(&rval, p, max, var_hash TSRMLS_CC)
362365
typedef int strlen_t;
363366
#else

library.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
3333
# endif
3434
#endif
3535

36+
#if (PHP_MAJOR_VERSION < 7)
37+
int (*_add_next_index_string)(zval *, const char *, int) = &add_next_index_string;
38+
int (*_add_next_index_stringl)(zval *, const char *, uint, int) = &add_next_index_stringl;
39+
int (*_add_assoc_bool_ex)(zval *, const char *, uint, int) = &add_assoc_bool_ex;
40+
int (*_add_assoc_long_ex)(zval *, const char *, uint, long) = &add_assoc_long_ex;
41+
int (*_add_assoc_double_ex)(zval *, const char *, uint, double) = &add_assoc_double_ex;
42+
int (*_add_assoc_string_ex)(zval *, const char *, uint, char *, int) = &add_assoc_string_ex;
43+
int (*_add_assoc_stringl_ex)(zval *, const char *, uint, char *, uint, int) = &add_assoc_stringl_ex;
44+
int (*_add_assoc_zval_ex)(zval *, const char *, uint, zval *) = &add_assoc_zval_ex;
45+
void (*_php_var_serialize)(smart_str *, zval **, php_serialize_data_t * TSRMLS_DC) = &php_var_serialize;
46+
int (*_php_var_unserialize)(zval **, const unsigned char **, const unsigned char *, php_unserialize_data_t * TSRMLS_DC) = &php_var_unserialize;
47+
#endif
48+
3649
extern zend_class_entry *redis_ce;
3750
extern zend_class_entry *redis_exception_ce;
3851

@@ -297,7 +310,7 @@ PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS,
297310

298311
/* Multibulk response, {[pattern], type, channel, payload } */
299312
while(1) {
300-
zval *z_type, *z_chan, *z_pat, *z_data;
313+
zval *z_type, *z_chan, *z_pat = NULL, *z_data;
301314
HashTable *ht_tab;
302315
int tab_idx=1, is_pmsg;
303316

redis.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ redis_sock_get_instance(zval *id, RedisSock **redis_sock TSRMLS_DC, int no_throw
455455
*redis_sock = (RedisSock *)zend_list_find(Z_LVAL_P(socket), &resource_type);
456456
#else
457457
*redis_sock = NULL;
458+
458459
if (Z_RES_P(socket) != NULL) {
459460
*redis_sock = (RedisSock *)Z_RES_P(socket)->ptr;
460461
resource_type = Z_RES_P(socket)->type;
@@ -2674,7 +2675,7 @@ PHP_METHOD(Redis, object)
26742675

26752676
/* {{{ proto string Redis::getOption($option) */
26762677
PHP_METHOD(Redis, getOption) {
2677-
RedisSock *redis_sock;
2678+
RedisSock *redis_sock = NULL;
26782679

26792680
if (redis_sock_get_instance(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
26802681
RETURN_FALSE;
@@ -2687,7 +2688,7 @@ PHP_METHOD(Redis, getOption) {
26872688

26882689
/* {{{ proto string Redis::setOption(string $option, mixed $value) */
26892690
PHP_METHOD(Redis, setOption) {
2690-
RedisSock *redis_sock;
2691+
RedisSock *redis_sock = NULL;
26912692

26922693
if (redis_sock_get_instance(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
26932694
RETURN_FALSE;

redis_array_impl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ ra_index_keys(zval *z_pairs, zval *z_redis TSRMLS_DC) {
586586
zval zv, *z_new = &zv;
587587
#if (PHP_MAJOR_VERSION < 7)
588588
MAKE_STD_ZVAL(z_new);
589+
#else
590+
PHPREDIS_NOTUSED(z_val);
589591
#endif
590592

591593
if (zkey) {

redis_commands.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ int redis_zrangebyscore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
529529
ulong idx;
530530
HashTable *ht_opt;
531531

532+
PHPREDIS_NOTUSED(idx);
533+
532534
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|a", &key, &key_len,
533535
&start, &start_len, &end, &end_len, &z_opt)
534536
==FAILURE)
@@ -1051,7 +1053,7 @@ static int gen_varkey_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
10511053
int key_free, key_len, i, tail;
10521054
int single_array = 0, argc = ZEND_NUM_ARGS();
10531055
smart_string cmdstr = {0};
1054-
long timeout;
1056+
long timeout = 0;
10551057
short kslot = -1;
10561058
zend_string *zstr;
10571059

@@ -1211,6 +1213,8 @@ int redis_set_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
12111213
ulong idx;
12121214
zval *v;
12131215

1216+
PHPREDIS_NOTUSED(idx);
1217+
12141218
/* Iterate our option array */
12151219
ZEND_HASH_FOREACH_KEY_VAL(kt, idx, zkey, v) {
12161220
/* Detect PX or EX argument and validate timeout */
@@ -2734,6 +2738,8 @@ static void get_georadius_opts(HashTable *ht, int *withcoord, int *withdist,
27342738
zend_string *zkey;
27352739
zval *optval;
27362740

2741+
PHPREDIS_NOTUSED(idx);
2742+
27372743
/* Iterate over our argument array, collating which ones we have */
27382744
ZEND_HASH_FOREACH_KEY_VAL(ht, idx, zkey, optval) {
27392745
/* If the key is numeric it's a non value option */

0 commit comments

Comments
 (0)