Skip to content

Commit b9b383f

Browse files
authored
fix [-Wformat=] warning on 32-bit (phpredis#1750)
Use the portable `ZEND_LONG_FORMAT` family instead of C format specifiers
1 parent 201a975 commit b9b383f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cluster_library.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ unsigned short cluster_hash_key_zval(zval *z_key) {
552552
klen = Z_STRLEN_P(z_key);
553553
break;
554554
case IS_LONG:
555-
klen = snprintf(buf,sizeof(buf),"%ld",Z_LVAL_P(z_key));
555+
klen = snprintf(buf,sizeof(buf),ZEND_LONG_FMT,Z_LVAL_P(z_key));
556556
kptr = (const char *)buf;
557557
break;
558558
case IS_DOUBLE:

redis_array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ PHP_METHOD(RedisArray, mget)
926926
key_len = Z_STRLEN_P(data);
927927
key_lookup = Z_STRVAL_P(data);
928928
} else {
929-
key_len = snprintf(kbuf, sizeof(kbuf), "%ld", Z_LVAL_P(data));
929+
key_len = snprintf(kbuf, sizeof(kbuf), ZEND_LONG_FMT, Z_LVAL_P(data));
930930
key_lookup = (char*)kbuf;
931931
}
932932

@@ -1052,7 +1052,7 @@ PHP_METHOD(RedisArray, mset)
10521052
key_len = ZSTR_LEN(zkey);
10531053
key = ZSTR_VAL(zkey);
10541054
} else {
1055-
key_len = snprintf(kbuf, sizeof(kbuf), "%lu", idx);
1055+
key_len = snprintf(kbuf, sizeof(kbuf), ZEND_ULONG_FMT, idx);
10561056
key = kbuf;
10571057
}
10581058

redis_cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,7 @@ cluster_cmd_get_slot(redisCluster *c, zval *z_arg)
22452245

22462246
/* Inform the caller if they've passed bad data */
22472247
if (slot < 0) {
2248-
php_error_docref(0, E_WARNING, "Unknown node %s:%ld",
2248+
php_error_docref(0, E_WARNING, "Unknown node %s:" ZEND_LONG_FMT,
22492249
Z_STRVAL_P(z_host), Z_LVAL_P(z_port));
22502250
}
22512251
} else {

0 commit comments

Comments
 (0)