Skip to content

Commit c9357f8

Browse files
committed
Format string fixes
Conflicts: ext/pgsql/pgsql.c
1 parent 5983378 commit c9357f8

17 files changed

Lines changed: 60 additions & 45 deletions

File tree

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */
16381638
result = zend_symtable_update(ht, ZSTR_EMPTY_ALLOC(), value);
16391639
break;
16401640
case IS_RESOURCE:
1641-
zend_error(E_NOTICE, "Resource ID#" ZEND_LONG_FMT " used as offset, casting to integer (%pd)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key));
1641+
zend_error(E_NOTICE, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key));
16421642
result = zend_hash_index_update(ht, Z_RES_HANDLE_P(key), value);
16431643
break;
16441644
case IS_FALSE:

ext/iconv/iconv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
424424
char *p = strstr(get_output_encoding(), "//");
425425

426426
if (p) {
427-
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (size_t) strlen(mimetype), mimetype, (size_t)(p - get_output_encoding()), get_output_encoding());
427+
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int) (p - get_output_encoding()), get_output_encoding());
428428
} else {
429-
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (size_t) strlen(mimetype), mimetype, get_output_encoding());
429+
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, get_output_encoding());
430430
}
431431
if (content_type && SUCCESS == sapi_add_header(content_type, (uint)len, 0)) {
432432
SG(sapi_headers).send_default_content_type = 0;

ext/mcrypt/mcrypt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,15 @@ PHP_FUNCTION(mcrypt_generic_init)
564564
memset(iv_s, 0, iv_size + 1);
565565

566566
if (key_len > max_key_size) {
567-
php_error_docref(NULL, E_WARNING, "Key size too large; supplied length: %d, max: %d", key_len, max_key_size);
567+
php_error_docref(NULL, E_WARNING, "Key size too large; supplied length: %zd, max: %d", key_len, max_key_size);
568568
key_size = max_key_size;
569569
} else {
570570
key_size = (int)key_len;
571571
}
572572
memcpy(key_s, key, key_len);
573573

574574
if (iv_len != iv_size) {
575-
php_error_docref(NULL, E_WARNING, "Iv size incorrect; supplied length: %d, needed: %d", iv_len, iv_size);
575+
php_error_docref(NULL, E_WARNING, "Iv size incorrect; supplied length: %zd, needed: %d", iv_len, iv_size);
576576
if (iv_len > iv_size) {
577577
iv_len = iv_size;
578578
}

ext/openssl/openssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5213,14 +5213,14 @@ static zend_bool php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_
52135213
}
52145214

52155215
if (*piv_len < iv_required_len) {
5216-
php_error_docref(NULL, E_WARNING, "IV passed is only %d bytes long, cipher expects an IV of precisely %d bytes, padding with \\0", *piv_len, iv_required_len);
5216+
php_error_docref(NULL, E_WARNING, "IV passed is only %zd bytes long, cipher expects an IV of precisely %zd bytes, padding with \\0", *piv_len, iv_required_len);
52175217
memcpy(iv_new, *piv, *piv_len);
52185218
*piv_len = iv_required_len;
52195219
*piv = iv_new;
52205220
return 1;
52215221
}
52225222

5223-
php_error_docref(NULL, E_WARNING, "IV passed is %d bytes long which is longer than the %d expected by selected cipher, truncating", *piv_len, iv_required_len);
5223+
php_error_docref(NULL, E_WARNING, "IV passed is %zd bytes long which is longer than the %zd expected by selected cipher, truncating", *piv_len, iv_required_len);
52245224
memcpy(iv_new, *piv, iv_required_len);
52255225
*piv_len = iv_required_len;
52265226
*piv = iv_new;

ext/pdo/pdo_stmt.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,9 +2107,9 @@ static PHP_METHOD(PDOStatement, debugDumpParams)
21072107
RETURN_FALSE;
21082108
}
21092109

2110-
php_stream_printf(out, "SQL: [%d] %.*s\n",
2110+
php_stream_printf(out, "SQL: [%zd] %.*s\n",
21112111
stmt->query_stringlen,
2112-
stmt->query_stringlen, stmt->query_string);
2112+
(int) stmt->query_stringlen, stmt->query_string);
21132113

21142114
php_stream_printf(out, "Params: %d\n",
21152115
stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0);
@@ -2119,13 +2119,14 @@ static PHP_METHOD(PDOStatement, debugDumpParams)
21192119
zend_string *key = NULL;
21202120
ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) {
21212121
if (key) {
2122-
php_stream_printf(out, "Key: Name: [%d] %.*s\n", ZSTR_LEN(key), ZSTR_LEN(key), ZSTR_VAL(key));
2122+
php_stream_printf(out, "Key: Name: [%zd] %.*s\n",
2123+
ZSTR_LEN(key), (int) ZSTR_LEN(key), ZSTR_VAL(key));
21232124
} else {
21242125
php_stream_printf(out, "Key: Position #%pd:\n", num);
21252126
}
21262127

2127-
php_stream_printf(out, "paramno=%pd\nname=[%d] \"%.*s\"\nis_param=%d\nparam_type=%d\n",
2128-
param->paramno, param->name? ZSTR_LEN(param->name) : 0, param->name? ZSTR_LEN(param->name) : 0,
2128+
php_stream_printf(out, "paramno=%pd\nname=[%zd] \"%.*s\"\nis_param=%d\nparam_type=%d\n",
2129+
param->paramno, param->name ? ZSTR_LEN(param->name) : 0, param->name ? (int) ZSTR_LEN(param->name) : 0,
21292130
param->name ? ZSTR_VAL(param->name) : "",
21302131
param->is_param,
21312132
param->param_type);

ext/standard/pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ PHP_FUNCTION(unpack)
986986
/* Reached end of input for '*' repeater */
987987
break;
988988
} else {
989-
php_error_docref(NULL, E_WARNING, "Type %c: not enough input, need %d, have %d", type, size, inputlen - inputpos);
989+
php_error_docref(NULL, E_WARNING, "Type %c: not enough input, need %d, have " ZEND_LONG_FMT, type, size, inputlen - inputpos);
990990
zval_dtor(return_value);
991991
RETURN_FALSE;
992992
}

ext/standard/var.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
108108
php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
109109
break;
110110
case IS_STRING:
111-
php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
111+
php_printf("%sstring(%zd) \"", COMMON, Z_STRLEN_P(struc));
112112
PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
113113
PUTS("\"\n");
114114
break;
@@ -278,7 +278,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
278278
php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
279279
break;
280280
case IS_STRING:
281-
php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
281+
php_printf("%sstring(%zd) \"", COMMON, Z_STRLEN_P(struc));
282282
PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
283283
php_printf("\" refcount(%u)\n", Z_REFCOUNTED_P(struc) ? Z_REFCOUNT_P(struc) : 1);
284284
break;
@@ -336,7 +336,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
336336
break;
337337
case IS_RESOURCE: {
338338
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc));
339-
php_printf("%sresource(" ZEND_LONG_FMT ") of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
339+
php_printf("%sresource(%d) of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
340340
break;
341341
}
342342
case IS_REFERENCE:
@@ -1045,7 +1045,8 @@ PHP_FUNCTION(unserialize)
10451045
}
10461046
zval_ptr_dtor(return_value);
10471047
if (!EG(exception)) {
1048-
php_error_docref(NULL, E_NOTICE, "Error at offset " ZEND_LONG_FMT " of %d bytes", (zend_long)((char*)p - buf), buf_len);
1048+
php_error_docref(NULL, E_NOTICE, "Error at offset " ZEND_LONG_FMT " of %zd bytes",
1049+
(zend_long)((char*)p - buf), buf_len);
10491050
}
10501051
RETURN_FALSE;
10511052
}

ext/zip/php_zip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char
331331
}
332332

333333
if (Z_STRLEN_P(option) >= MAXPATHLEN) {
334-
php_error_docref(NULL, E_WARNING, "remove_path string is too long (max: %i, %i given)",
334+
php_error_docref(NULL, E_WARNING, "remove_path string is too long (max: %d, %zd given)",
335335
MAXPATHLEN - 1, Z_STRLEN_P(option));
336336
return -1;
337337
}
@@ -351,7 +351,7 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char
351351
}
352352

353353
if (Z_STRLEN_P(option) >= MAXPATHLEN) {
354-
php_error_docref(NULL, E_WARNING, "add_path string too long (max: %i, %i given)",
354+
php_error_docref(NULL, E_WARNING, "add_path string too long (max: %d, %zd given)",
355355
MAXPATHLEN - 1, Z_STRLEN_P(option));
356356
return -1;
357357
}

ext/zlib/zlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ PHP_FUNCTION(deflate_init)
10641064
case Z_DEFAULT_STRATEGY:
10651065
break;
10661066
default:
1067-
php_error_docref(NULL, E_WARNING, "strategy must be one of ZLIB_FILTERED, ZLIB_HUFFMAN_ONLY, ZLIB_RLE, ZLIB_FIXED or ZLIB_DEFAULT_STRATEGY", strategy);
1067+
php_error_docref(NULL, E_WARNING, "strategy must be one of ZLIB_FILTERED, ZLIB_HUFFMAN_ONLY, ZLIB_RLE, ZLIB_FIXED or ZLIB_DEFAULT_STRATEGY");
10681068
RETURN_FALSE;
10691069
}
10701070

sapi/phpdbg/phpdbg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static PHP_FUNCTION(phpdbg_get_executable)
558558
insert_ht = phpdbg_add_empty_array(Z_ARR_P(return_value), func->op_array.filename);
559559

560560
if (by_function) {
561-
zend_string *fn_name = strpprintf(ZSTR_LEN(name) + ZSTR_LEN(func->op_array.function_name) + 2, "%.*s::%.*s", ZSTR_LEN(name), ZSTR_VAL(name), ZSTR_LEN(func->op_array.function_name), ZSTR_VAL(func->op_array.function_name));
561+
zend_string *fn_name = strpprintf(ZSTR_LEN(name) + ZSTR_LEN(func->op_array.function_name) + 2, "%.*s::%.*s", (int) ZSTR_LEN(name), ZSTR_VAL(name), (int) ZSTR_LEN(func->op_array.function_name), ZSTR_VAL(func->op_array.function_name));
562562
insert_ht = phpdbg_add_empty_array(insert_ht, fn_name);
563563
zend_string_release(fn_name);
564564
}
@@ -654,7 +654,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
654654
if (last_scope == NULL) {
655655
fn_name = zend_string_copy(last_function);
656656
} else {
657-
fn_name = strpprintf(ZSTR_LEN(last_function) + ZSTR_LEN(last_scope->name) + 2, "%.*s::%.*s", ZSTR_LEN(last_scope->name), ZSTR_VAL(last_scope->name), ZSTR_LEN(last_function), ZSTR_VAL(last_function));
657+
fn_name = strpprintf(ZSTR_LEN(last_function) + ZSTR_LEN(last_scope->name) + 2, "%.*s::%.*s", (int) ZSTR_LEN(last_scope->name), ZSTR_VAL(last_scope->name), (int) ZSTR_LEN(last_function), ZSTR_VAL(last_function));
658658
}
659659
insert_ht = phpdbg_add_empty_array(Z_ARR_P(return_value), fn_name);
660660
zend_string_release(fn_name);
@@ -896,7 +896,7 @@ static inline size_t php_sapi_phpdbg_ub_write(const char *message, size_t length
896896
if (PHPDBG_G(socket_fd) != -1 && !(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) {
897897
send(PHPDBG_G(socket_fd), message, length, 0);
898898
}
899-
return phpdbg_script(P_STDOUT, "%.*s", length, message);
899+
return phpdbg_script(P_STDOUT, "%.*s", (int) length, message);
900900
} /* }}} */
901901

902902
/* beginning of struct, see main/streams/plain_wrapper.c line 111 */

0 commit comments

Comments
 (0)