Skip to content

Commit

Permalink
Address more Clang warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmb69 committed Jan 18, 2025
1 parent 709c0a9 commit d00dd60
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ext/com_dotnet/com_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name
ITypeComp_Release(bindptr.lptcomp);
break;

case DESCKIND_NONE:
default:
break;
}
if (TI) {
Expand Down
2 changes: 1 addition & 1 deletion ext/com_dotnet/com_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static void generate_dispids(php_dispatchex *disp)
zend_string *name = NULL;
zval *tmp, tmp2;
int keytype;
zend_long pid;
zend_ulong pid;

if (disp->dispid_to_name == NULL) {
ALLOC_HASHTABLE(disp->dispid_to_name);
Expand Down
3 changes: 2 additions & 1 deletion ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,10 @@ static zend_always_inline zend_string *zend_ffi_mangled_func_name(zend_string *n
case FFI_VECTORCALL_PARTIAL:
return strpprintf(0, "%s@@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type));
# endif
default:
return zend_string_copy(name);
}
#endif
return zend_string_copy(name);
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion ext/gd/libgd/gd_interpolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include "gdhelpers.h"
#include "gd_intern.h"

#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
# pragma optimize("t", on)
# include <emmintrin.h>
#endif
Expand Down
4 changes: 2 additions & 2 deletions ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char

if (strncasecmp(resolved_path, "file:/", pre_len) == 0
&& '/' != resolved_path[pre_len]) {
xmlChar *tmp = xmlStrdup(resolved_path + pre_len);
xmlChar *tmp = xmlStrdup(BAD_CAST (resolved_path + pre_len));
xmlFree(resolved_path);
resolved_path = tmp;
resolved_path = (char *) tmp;
}
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions ext/mysqlnd/mysqlnd_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ static mysqlnd_rsa_t
mysqlnd_sha256_get_rsa_from_pem(const char *buf, size_t len)
{
BCRYPT_KEY_HANDLE ret = 0;
LPSTR der_buf = NULL;
BYTE *der_buf = NULL;
DWORD der_len;
CERT_PUBLIC_KEY_INFO *key_info = NULL;
DWORD key_info_len;
Expand Down Expand Up @@ -789,7 +789,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub

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

*auth_data_len = server_public_key_len;
ret = malloc(*auth_data_len);
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
NULL, 0, ret, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
DBG_RETURN(0);
Expand Down Expand Up @@ -1052,7 +1052,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv

ZeroMemory(&padding_info, sizeof padding_info);
padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
DBG_RETURN(0);
}
Expand All @@ -1071,7 +1071,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv
}

*crypted = emalloc(server_public_key_len);
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, (zend_uchar *) xor_str, passwd_len + 1, &padding_info,
NULL, 0, *crypted, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
DBG_RETURN(0);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqlnd/mysqlnd_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long se
retval = php_select(max_fd + 1, &rfds, &wfds, &efds, tv_p);

if (retval == -1) {
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=%d)",
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=" PHP_SOCKET_FMT ")",
errno, strerror(errno), max_fd);
DBG_RETURN(FAIL);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ static int php_openssl_win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx,
err_code = e;
}

php_error_docref(NULL, E_WARNING, "Error encoding X509 certificate: %d: %s", err_code, ERR_error_string(err_code, err_buf));
php_error_docref(NULL, E_WARNING, "Error encoding X509 certificate: %lu: %s", err_code, ERR_error_string(err_code, err_buf));
RETURN_CERT_VERIFY_FAILURE(SSL_R_CERTIFICATE_VERIFY_FAILED);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/standard/streamsfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ PHP_FUNCTION(stream_select)
retval = php_select(max_fd+1, &rfds, &wfds, &efds, tv_p);

if (retval == -1) {
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=%d)",
php_error_docref(NULL, E_WARNING, "Unable to select [%d]: %s (max_fd=" PHP_SOCKET_FMT ")",
errno, strerror(errno), max_fd);
RETURN_FALSE;
}
Expand Down
2 changes: 2 additions & 0 deletions main/php_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ END_EXTERN_C()

#ifdef PHP_WIN32
typedef SOCKET php_socket_t;
#define PHP_SOCKET_FMT "%" PRIxPTR
#else
typedef int php_socket_t;
#define PHP_SOCKET_FMT "%d"
#endif

#ifdef PHP_WIN32
Expand Down
2 changes: 1 addition & 1 deletion main/streams/plain_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ static int php_stdiop_cast(php_stream *stream, int castas, void **ret)
}

*(FILE**)ret = data->file;
data->fd = SOCK_ERR;
data->fd = (int) SOCK_ERR;
}
return SUCCESS;

Expand Down
4 changes: 2 additions & 2 deletions win32/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_
memset(name, '\0', max_name+1);
memset(value, '\0', max_value+1);

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

Expand Down Expand Up @@ -287,7 +287,7 @@ char *GetIniPathFromRegistry()
if (OpenPhpRegistryKey(NULL, &hKey)) {
DWORD buflen = MAXPATHLEN;
reg_location = emalloc(MAXPATHLEN+1);
if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, reg_location, &buflen) != ERROR_SUCCESS) {
if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, (LPBYTE) reg_location, &buflen) != ERROR_SUCCESS) {
RegCloseKey(hKey);
efree(reg_location);
reg_location = NULL;
Expand Down
4 changes: 2 additions & 2 deletions win32/wsyslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void syslog(int priority, const char *message, ...)

void vsyslog(int priority, const char *message, va_list args)
{
LPTSTR strs[2];
LPCSTR strs[2];
unsigned short etype;
char *tmp = NULL;
DWORD evid;
Expand Down Expand Up @@ -120,7 +120,7 @@ void vsyslog(int priority, const char *message, va_list args)

/* report the event */
if (strsw[0] && strsw[1]) {
ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strsw, NULL);
ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, (LPCWSTR *) strsw, NULL);
free(strsw[0]);
free(strsw[1]);
efree(tmp);
Expand Down

0 comments on commit d00dd60

Please sign in to comment.