Fix [-Wundef] warning in PDO MySQL extension

This commit is contained in:
George Peter Banyard 2020-05-20 15:41:13 +02:00
parent db7dc2fa2f
commit c932cc841a
4 changed files with 24 additions and 24 deletions

View file

@ -32,7 +32,7 @@
#endif #endif
#include "zend_exceptions.h" #include "zend_exceptions.h"
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
# define pdo_mysql_init(persistent) mysqlnd_init(MYSQLND_CLIENT_NO_FLAG, persistent) # define pdo_mysql_init(persistent) mysqlnd_init(MYSQLND_CLIENT_NO_FLAG, persistent)
#else #else
# define pdo_mysql_init(persistent) mysql_init(NULL) # define pdo_mysql_init(persistent) mysql_init(NULL)
@ -224,7 +224,7 @@ static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len
if (S->num_params) { if (S->num_params) {
S->params_given = 0; S->params_given = 0;
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
S->params = NULL; S->params = NULL;
#else #else
S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND)); S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
@ -444,7 +444,7 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_
ZVAL_STRING(return_value, (char *)mysql_get_host_info(H->server)); ZVAL_STRING(return_value, (char *)mysql_get_host_info(H->server));
break; break;
case PDO_ATTR_SERVER_INFO: { case PDO_ATTR_SERVER_INFO: {
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
zend_string *tmp; zend_string *tmp;
if (mysqlnd_stat(H->server, &tmp) == PASS) { if (mysqlnd_stat(H->server, &tmp) == PASS) {
@ -577,7 +577,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
|CLIENT_MULTI_RESULTS |CLIENT_MULTI_RESULTS
#endif #endif
; ;
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
size_t dbname_len = 0; size_t dbname_len = 0;
size_t password_len = 0; size_t password_len = 0;
#endif #endif
@ -610,7 +610,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
pdo_mysql_error(dbh); pdo_mysql_error(dbh);
goto cleanup; goto cleanup;
} }
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
if (dbh->is_persistent) { if (dbh->is_persistent) {
mysqlnd_restart_psession(H->server); mysqlnd_restart_psession(H->server);
} }

View file

@ -100,7 +100,7 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
} }
} }
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (!S->stmt && S->current_data) { if (!S->stmt && S->current_data) {
mnd_free(S->current_data); mnd_free(S->current_data);
} }
@ -339,13 +339,13 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
{ {
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
pdo_mysql_db_handle *H = S->H; pdo_mysql_db_handle *H = S->H;
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
zend_long row_count; zend_long row_count;
#endif #endif
PDO_DBG_ENTER("pdo_mysql_stmt_next_rowset"); PDO_DBG_ENTER("pdo_mysql_stmt_next_rowset");
PDO_DBG_INF_FMT("stmt=%p", S->stmt); PDO_DBG_INF_FMT("stmt=%p", S->stmt);
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (!H->emulate_prepare) { if (!H->emulate_prepare) {
if (!mysqlnd_stmt_more_results(S->stmt)) { if (!mysqlnd_stmt_more_results(S->stmt)) {
PDO_DBG_RETURN(0); PDO_DBG_RETURN(0);
@ -416,7 +416,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
/* No more results */ /* No more results */
PDO_DBG_RETURN(0); PDO_DBG_RETURN(0);
} }
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (mysql_next_result(H->server) == FAIL) { if (mysql_next_result(H->server) == FAIL) {
pdo_mysql_error_stmt(stmt); pdo_mysql_error_stmt(stmt);
PDO_DBG_RETURN(0); PDO_DBG_RETURN(0);
@ -491,7 +491,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
parameter = Z_REFVAL(param->parameter); parameter = Z_REFVAL(param->parameter);
} }
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL || (Z_TYPE_P(parameter) == IS_NULL)) { if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL || (Z_TYPE_P(parameter) == IS_NULL)) {
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL); mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL);
PDO_DBG_RETURN(1); PDO_DBG_RETURN(1);
@ -537,7 +537,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
; ;
} }
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
/* Is it really correct to check the zval's type? - But well, that's what the old code below does, too */ /* Is it really correct to check the zval's type? - But well, that's what the old code below does, too */
PDO_DBG_INF_FMT("param->parameter->type=%d", Z_TYPE(param->parameter)); PDO_DBG_INF_FMT("param->parameter->type=%d", Z_TYPE(param->parameter));
if (!Z_ISREF(param->parameter)) { if (!Z_ISREF(param->parameter)) {
@ -614,7 +614,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* {{{ */ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* {{{ */
{ {
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
zend_bool fetched_anything; zend_bool fetched_anything;
PDO_DBG_ENTER("pdo_mysql_stmt_fetch"); PDO_DBG_ENTER("pdo_mysql_stmt_fetch");
@ -653,14 +653,14 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
strcpy(stmt->error_code, "HY000"); strcpy(stmt->error_code, "HY000");
PDO_DBG_RETURN(0); PDO_DBG_RETURN(0);
} }
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (!S->stmt && S->current_data) { if (!S->stmt && S->current_data) {
mnd_free(S->current_data); mnd_free(S->current_data);
} }
#endif /* PDO_USE_MYSQLND */ #endif /* PDO_USE_MYSQLND */
if ((S->current_data = mysql_fetch_row(S->result)) == NULL) { if ((S->current_data = mysql_fetch_row(S->result)) == NULL) {
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (S->result->unbuf && !S->result->unbuf->eof_reached && mysql_errno(S->H->server)) { if (S->result->unbuf && !S->result->unbuf->eof_reached && mysql_errno(S->H->server)) {
#else #else
if (!S->result->eof && mysql_errno(S->H->server)) { if (!S->result->eof && mysql_errno(S->H->server)) {
@ -743,7 +743,7 @@ static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_
/* error invalid column */ /* error invalid column */
PDO_DBG_RETURN(0); PDO_DBG_RETURN(0);
} }
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
if (S->stmt) { if (S->stmt) {
Z_TRY_ADDREF(S->stmt->data->result_bind[colno].zv); Z_TRY_ADDREF(S->stmt->data->result_bind[colno].zv);
*ptr = (char*)&S->stmt->data->result_bind[colno].zv; *ptr = (char*)&S->stmt->data->result_bind[colno].zv;

View file

@ -48,7 +48,7 @@ ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql)
# ifdef PHP_MYSQL_UNIX_SOCK_ADDR # ifdef PHP_MYSQL_UNIX_SOCK_ADDR
# define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR # define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
# else # else
# if !PHP_WIN32 # ifndef PHP_WIN32
# define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock" # define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
# else # else
# define PDO_MYSQL_UNIX_ADDR NULL # define PDO_MYSQL_UNIX_ADDR NULL
@ -143,7 +143,7 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
static PHP_MSHUTDOWN_FUNCTION(pdo_mysql) static PHP_MSHUTDOWN_FUNCTION(pdo_mysql)
{ {
php_pdo_unregister_driver(&pdo_mysql_driver); php_pdo_unregister_driver(&pdo_mysql_driver);
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
UNREGISTER_INI_ENTRIES(); UNREGISTER_INI_ENTRIES();
#endif #endif
@ -169,7 +169,7 @@ static PHP_MINFO_FUNCTION(pdo_mysql)
/* }}} */ /* }}} */
#if PDO_USE_MYSQLND && PDO_DBG_ENABLED #if defined(PDO_USE_MYSQLND) && PDO_DBG_ENABLED
/* {{{ PHP_RINIT_FUNCTION /* {{{ PHP_RINIT_FUNCTION
*/ */
static PHP_RINIT_FUNCTION(pdo_mysql) static PHP_RINIT_FUNCTION(pdo_mysql)
@ -245,7 +245,7 @@ zend_module_entry pdo_mysql_module_entry = {
pdo_mysql_functions, pdo_mysql_functions,
PHP_MINIT(pdo_mysql), PHP_MINIT(pdo_mysql),
PHP_MSHUTDOWN(pdo_mysql), PHP_MSHUTDOWN(pdo_mysql),
#if PDO_USE_MYSQLND && PDO_DBG_ENABLED #if defined(PDO_USE_MYSQLND) && PDO_DBG_ENABLED
PHP_RINIT(pdo_mysql), PHP_RINIT(pdo_mysql),
PHP_RSHUTDOWN(pdo_mysql), PHP_RSHUTDOWN(pdo_mysql),
#else #else

View file

@ -19,7 +19,7 @@
#ifndef PHP_PDO_MYSQL_INT_H #ifndef PHP_PDO_MYSQL_INT_H
#define PHP_PDO_MYSQL_INT_H #define PHP_PDO_MYSQL_INT_H
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
# include "ext/mysqlnd/mysqlnd.h" # include "ext/mysqlnd/mysqlnd.h"
# include "ext/mysqlnd/mysqlnd_libmysql_compat.h" # include "ext/mysqlnd/mysqlnd_libmysql_compat.h"
# define PDO_MYSQL_PARAM_BIND MYSQLND_PARAM_BIND # define PDO_MYSQL_PARAM_BIND MYSQLND_PARAM_BIND
@ -57,7 +57,7 @@ static inline void PDO_DBG_ENTER(char *func_name) {}
#endif #endif
#if defined(PDO_USE_MYSQLND) #ifdef PDO_USE_MYSQLND
#include "ext/mysqlnd/mysqlnd_debug.h" #include "ext/mysqlnd/mysqlnd_debug.h"
#endif #endif
@ -101,7 +101,7 @@ typedef struct {
unsigned buffered:1; unsigned buffered:1;
unsigned emulate_prepare:1; unsigned emulate_prepare:1;
unsigned fetch_table_names:1; unsigned fetch_table_names:1;
#if !PDO_USE_MYSQLND #ifndef PDO_USE_MYSQLND
zend_ulong max_buffer_size; zend_ulong max_buffer_size;
#endif #endif
@ -117,13 +117,13 @@ typedef struct {
MYSQL_RES *result; MYSQL_RES *result;
const MYSQL_FIELD *fields; const MYSQL_FIELD *fields;
MYSQL_ROW current_data; MYSQL_ROW current_data;
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
const size_t *current_lengths; const size_t *current_lengths;
#else #else
zend_long *current_lengths; zend_long *current_lengths;
#endif #endif
pdo_mysql_error_info einfo; pdo_mysql_error_info einfo;
#if PDO_USE_MYSQLND #ifdef PDO_USE_MYSQLND
MYSQLND_STMT *stmt; MYSQLND_STMT *stmt;
#else #else
MYSQL_STMT *stmt; MYSQL_STMT *stmt;