Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2559f72

Browse files
authored
Merge pull request phpredis#1026 from yatsukhnenko/develop
TravisCI: clang + refactoring
2 parents 6d37af0 + 6d6deae commit 2559f72

File tree

4 files changed

+18
-33
lines changed

4 files changed

+18
-33
lines changed

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ php:
88
- 7.0
99
- 7.1
1010
- nightly
11+
env: CC=gcc
1112
matrix:
13+
include:
14+
- env: CC=clang
15+
php: 7.0
16+
- env: CC=clang
17+
php: 7.1
18+
- env: CC=clang
19+
php: nightly
1220
allow_failures:
1321
- php: nightly
22+
addons:
23+
apt:
24+
packages: clang
1425
before_install: phpize
1526
install: ./configure CFLAGS=-Wall --prefix=/usr && sudo make install
1627
before_script:

cluster_library.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -2242,15 +2242,10 @@ PHP_REDIS_API void cluster_mset_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster
22422242

22432243
// Set our return if it's the last call
22442244
if(mctx->last) {
2245-
#if (PHP_MAJOR_VERSION < 7)
2246-
zend_bool bval = Z_LVAL_P(mctx->z_multi);
2247-
#else
2248-
zend_bool bval = (Z_TYPE_P(mctx->z_multi) == IS_TRUE);
2249-
#endif
22502245
if(CLUSTER_IS_ATOMIC(c)) {
2251-
ZVAL_BOOL(return_value, bval);
2246+
ZVAL_BOOL(return_value, zval_is_true(mctx->z_multi));
22522247
} else {
2253-
add_next_index_bool(&c->multi_resp, bval);
2248+
add_next_index_bool(&c->multi_resp, zval_is_true(mctx->z_multi));
22542249
}
22552250
efree(mctx->z_multi);
22562251
}

redis_array.c

+4-21
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "ext/standard/info.h"
2626
#include "php_ini.h"
2727
#include "php_redis.h"
28-
#include "redis_array.h"
2928
#include <zend_exceptions.h>
3029

3130
#include "library.h"
@@ -255,29 +254,17 @@ PHP_METHOD(RedisArray, __construct)
255254

256255
/* extract index option. */
257256
if ((zpData = zend_hash_str_find(hOpts, "index", sizeof("index") - 1)) != NULL) {
258-
#if (PHP_MAJOR_VERSION < 7)
259-
b_index = (Z_TYPE_P(zpData) == IS_BOOL && Z_LVAL_P(zpData));
260-
#else
261-
b_index = (Z_TYPE_P(zpData) == IS_TRUE);
262-
#endif
257+
b_index = zval_is_true(zpData);
263258
}
264259

265260
/* extract autorehash option. */
266261
if ((zpData = zend_hash_str_find(hOpts, "autorehash", sizeof("autorehash") - 1)) != NULL) {
267-
#if (PHP_MAJOR_VERSION < 7)
268-
b_autorehash = (Z_TYPE_P(zpData) == IS_BOOL && Z_LVAL_P(zpData));
269-
#else
270-
b_autorehash = (Z_TYPE_P(zpData) == IS_TRUE);
271-
#endif
262+
b_autorehash = zval_is_true(zpData);
272263
}
273264

274265
/* pconnect */
275266
if ((zpData = zend_hash_str_find(hOpts, "pconnect", sizeof("pconnect") - 1)) != NULL) {
276-
#if (PHP_MAJOR_VERSION < 7)
277-
b_pconnect = (Z_TYPE_P(zpData) == IS_BOOL && Z_LVAL_P(zpData));
278-
#else
279-
b_pconnect = (Z_TYPE_P(zpData) == IS_TRUE);
280-
#endif
267+
b_pconnect = zval_is_true(zpData);
281268
}
282269

283270
/* extract retry_interval option. */
@@ -293,11 +280,7 @@ PHP_METHOD(RedisArray, __construct)
293280

294281
/* extract lazy connect option. */
295282
if ((zpData = zend_hash_str_find(hOpts, "lazy_connect", sizeof("lazy_connect") - 1)) != NULL) {
296-
#if (PHP_MAJOR_VERSION < 7)
297-
b_lazy_connect = (Z_TYPE_P(zpData) == IS_BOOL && Z_LVAL_P(zpData));
298-
#else
299-
b_lazy_connect = (Z_TYPE_P(zpData) == IS_TRUE);
300-
#endif
283+
b_lazy_connect = zval_is_true(zpData);
301284
}
302285

303286
/* extract connect_timeout option */

redis_commands.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -2439,11 +2439,7 @@ int redis_sort_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
24392439
// ALPHA
24402440
if (((z_ele = zend_hash_str_find(ht_opts, "alpha", sizeof("alpha") - 1)) != NULL ||
24412441
(z_ele = zend_hash_str_find(ht_opts, "ALPHA", sizeof("ALPHA") - 1)) != NULL) &&
2442-
#if (PHP_MAJOR_VERSION < 7)
2443-
(Z_TYPE_P(z_ele) == IS_BOOL && Z_LVAL_P(z_ele))
2444-
#else
2445-
(Z_TYPE_P(z_ele) == IS_TRUE)
2446-
#endif
2442+
zval_is_true(z_ele)
24472443
) {
24482444
add_next_index_stringl(&z_argv, "ALPHA", sizeof("ALPHA") - 1);
24492445
}

0 commit comments

Comments
 (0)