Skip to content

Commit aa76127

Browse files
authored
Address more Clang warnings (GH-17506)
We prefer clean solutions (such as declaring the proper type in the first place, or introducing a portable format specifier) where easily possible, but resort to casts otherwise. We also port libgd/libgd@f1480ab.
1 parent 75bd1a9 commit aa76127

File tree

11 files changed

+20
-20
lines changed

11 files changed

+20
-20
lines changed

ext/com_dotnet/com_handlers.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name
353353
ITypeComp_Release(bindptr.lptcomp);
354354
break;
355355

356-
case DESCKIND_NONE:
356+
default:
357357
break;
358358
}
359359
if (TI) {

ext/ffi/ffi.c

+3
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ static zend_always_inline zend_string *zend_ffi_mangled_func_name(zend_string *n
900900
case FFI_VECTORCALL_PARTIAL:
901901
return strpprintf(0, "%s@@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type));
902902
# endif
903+
default:
904+
/* other calling conventions don't apply name mangling */
905+
break;
903906
}
904907
#endif
905908
return zend_string_copy(name);

ext/gd/libgd/gd_interpolation.c

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@
6262
#include "gdhelpers.h"
6363
#include "gd_intern.h"
6464

65-
#ifdef _MSC_VER
66-
# pragma optimize("t", on)
67-
# include <emmintrin.h>
68-
#endif
69-
7065
static gdImagePtr gdImageScaleBilinear(gdImagePtr im,
7166
const unsigned int new_width,
7267
const unsigned int new_height);

ext/libxml/libxml.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
433433

434434
if (strncasecmp(resolved_path, "file:/", pre_len) == 0
435435
&& '/' != resolved_path[pre_len]) {
436-
xmlChar *tmp = xmlStrdup(resolved_path + pre_len);
436+
xmlChar *tmp = xmlStrdup(BAD_CAST (resolved_path + pre_len));
437437
xmlFree(resolved_path);
438-
resolved_path = tmp;
438+
resolved_path = (char *) tmp;
439439
}
440440
}
441441
#endif

ext/mysqlnd/mysqlnd_auth.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ static mysqlnd_rsa_t
746746
mysqlnd_sha256_get_rsa_from_pem(const char *buf, size_t len)
747747
{
748748
BCRYPT_KEY_HANDLE ret = 0;
749-
LPSTR der_buf = NULL;
749+
BYTE *der_buf = NULL;
750750
DWORD der_len;
751751
CERT_PUBLIC_KEY_INFO *key_info = NULL;
752752
DWORD key_info_len;
@@ -789,7 +789,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub
789789

790790
ZeroMemory(&padding_info, sizeof padding_info);
791791
padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
792-
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
792+
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
793793
NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
794794
DBG_RETURN(0);
795795
}
@@ -809,7 +809,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub
809809

810810
*auth_data_len = server_public_key_len;
811811
ret = malloc(*auth_data_len);
812-
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
812+
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
813813
NULL, 0, ret, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
814814
BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
815815
DBG_RETURN(0);
@@ -1052,7 +1052,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv
10521052

10531053
ZeroMemory(&padding_info, sizeof padding_info);
10541054
padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
1055-
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
1055+
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
10561056
NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
10571057
DBG_RETURN(0);
10581058
}
@@ -1071,7 +1071,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv
10711071
}
10721072

10731073
*crypted = emalloc(server_public_key_len);
1074-
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
1074+
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
10751075
NULL, 0, *crypted, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
10761076
BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
10771077
DBG_RETURN(0);

ext/mysqlnd/mysqlnd_connection.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long se
22412241
retval = php_select(max_fd + 1, &rfds, &wfds, &efds, tv_p);
22422242

22432243
if (retval == -1) {
2244-
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=%d)",
2244+
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=" PHP_SOCKET_FMT ")",
22452245
errno, strerror(errno), max_fd);
22462246
DBG_RETURN(FAIL);
22472247
}

ext/openssl/xp_ssl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ static int php_openssl_win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx,
700700
err_code = e;
701701
}
702702

703-
php_error_docref(NULL, E_WARNING, "Error encoding X509 certificate: %d: %s", err_code, ERR_error_string(err_code, err_buf));
703+
php_error_docref(NULL, E_WARNING, "Error encoding X509 certificate: %lu: %s", err_code, ERR_error_string(err_code, err_buf));
704704
RETURN_CERT_VERIFY_FAILURE(SSL_R_CERTIFICATE_VERIFY_FAILED);
705705
}
706706

ext/standard/streamsfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ PHP_FUNCTION(stream_select)
859859
retval = php_select(max_fd+1, &rfds, &wfds, &efds, tv_p);
860860

861861
if (retval == -1) {
862-
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=%d)",
862+
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=" PHP_SOCKET_FMT ")",
863863
errno, strerror(errno), max_fd);
864864
RETURN_FALSE;
865865
}

main/php_network.h

+2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ END_EXTERN_C()
9696

9797
#ifdef PHP_WIN32
9898
typedef SOCKET php_socket_t;
99+
#define PHP_SOCKET_FMT "%" PRIxPTR
99100
#else
100101
typedef int php_socket_t;
102+
#define PHP_SOCKET_FMT "%d"
101103
#endif
102104

103105
#ifdef PHP_WIN32

win32/registry.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_
9494
memset(name, '\0', max_name+1);
9595
memset(value, '\0', max_value+1);
9696

97-
if (RegEnumValue(key, i, name, &name_len, NULL, &type, value, &value_len) == ERROR_SUCCESS) {
97+
if (RegEnumValue(key, i, name, &name_len, NULL, &type, (LPBYTE) value, &value_len) == ERROR_SUCCESS) {
9898
if ((type == REG_SZ) || (type == REG_EXPAND_SZ)) {
9999
zval data;
100100

@@ -287,7 +287,7 @@ char *GetIniPathFromRegistry()
287287
if (OpenPhpRegistryKey(NULL, &hKey)) {
288288
DWORD buflen = MAXPATHLEN;
289289
reg_location = emalloc(MAXPATHLEN+1);
290-
if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, reg_location, &buflen) != ERROR_SUCCESS) {
290+
if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, (LPBYTE) reg_location, &buflen) != ERROR_SUCCESS) {
291291
RegCloseKey(hKey);
292292
efree(reg_location);
293293
reg_location = NULL;

win32/wsyslog.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void syslog(int priority, const char *message, ...)
8989

9090
void vsyslog(int priority, const char *message, va_list args)
9191
{
92-
LPTSTR strs[2];
92+
LPCSTR strs[2];
9393
unsigned short etype;
9494
char *tmp = NULL;
9595
DWORD evid;
@@ -120,7 +120,7 @@ void vsyslog(int priority, const char *message, va_list args)
120120

121121
/* report the event */
122122
if (strsw[0] && strsw[1]) {
123-
ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strsw, NULL);
123+
ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, (LPCWSTR *) strsw, NULL);
124124
free(strsw[0]);
125125
free(strsw[1]);
126126
efree(tmp);

0 commit comments

Comments
 (0)