]> granicus.if.org Git - php/commitdiff
Fix warnings when building against libmysqlclient
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 17 Sep 2020 12:23:25 +0000 (14:23 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 17 Sep 2020 13:02:35 +0000 (15:02 +0200)
At least for version 8.0 this is warning free now.

ext/mysqli/mysqli_api.c
ext/mysqli/php_mysqli_structs.h
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/php_pdo_mysql_int.h

index f559c3e8f9b842cf58d754524254d8629b4a3dfc..a22e710c7593191f412b8ad66a705980eed6e404 100644 (file)
@@ -370,7 +370,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc)
                int size;
                char *p = emalloc(size= var_cnt * (sizeof(char) + sizeof(VAR_BUFFER)));
                stmt->result.buf = (VAR_BUFFER *) p;
-               stmt->result.is_null = p + var_cnt * sizeof(VAR_BUFFER);
+               stmt->result.is_null = (my_bool *) (p + var_cnt * sizeof(VAR_BUFFER));
                memset(p, 0, size);
        }
 
@@ -903,7 +903,6 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
        zval                    *mysql_stmt;
        unsigned int    i;
        zend_ulong                      ret;
-       unsigned int    uval;
        my_ulonglong    llval;
 
 
@@ -940,8 +939,8 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
                                                    && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
                                                {
                                                        /* unsigned int (11) */
-                                                       uval= *(unsigned int *) stmt->result.buf[i].val;
-#if SIZEOF_ZEND_LONG==4
+#if SIZEOF_ZEND_LONG == 4
+                                                       unsigned int uval = *(unsigned int *) stmt->result.buf[i].val;
                                                        if (uval > INT_MAX) {
                                                                char *tmp, *p;
                                                                int j = 10;
index 6becb9845f6760b4f58f9ef663d9684ec01d3feb..ad46511d04c22180e73512b2b7c11586e8e2ac6f 100644 (file)
@@ -68,7 +68,7 @@ typedef struct {
        unsigned int    var_cnt;
        VAR_BUFFER              *buf;
        zval                    *vars;
-       char                    *is_null;
+       my_bool                 *is_null;
 } BIND_BUFFER;
 
 typedef struct {
index 9596bdd04f45c16f701c1f77266a4d6c34d52963..8c6f6a37f1d7b0dffcde3547cd79dbc92f10edf5 100644 (file)
@@ -353,7 +353,7 @@ static int mysql_handle_rollback(pdo_dbh_t *dbh)
 {
        PDO_DBG_ENTER("mysql_handle_rollback");
        PDO_DBG_INF_FMT("dbh=%p", dbh);
-       PDO_DBG_RETURN(0 <= mysql_rollback(((pdo_mysql_db_handle *)dbh->driver_data)->server));
+       PDO_DBG_RETURN(0 == mysql_rollback(((pdo_mysql_db_handle *)dbh->driver_data)->server));
 }
 /* }}} */
 
@@ -363,7 +363,7 @@ static inline int mysql_handle_autocommit(pdo_dbh_t *dbh)
        PDO_DBG_ENTER("mysql_handle_autocommit");
        PDO_DBG_INF_FMT("dbh=%p", dbh);
        PDO_DBG_INF_FMT("dbh->autocommit=%d", dbh->auto_commit);
-       PDO_DBG_RETURN(0 <= mysql_autocommit(((pdo_mysql_db_handle *)dbh->driver_data)->server, dbh->auto_commit));
+       PDO_DBG_RETURN(0 == mysql_autocommit(((pdo_mysql_db_handle *)dbh->driver_data)->server, dbh->auto_commit));
 }
 /* }}} */
 
@@ -515,11 +515,11 @@ static int pdo_mysql_check_liveness(pdo_dbh_t *dbh)
 /* {{{ pdo_mysql_request_shutdown */
 static void pdo_mysql_request_shutdown(pdo_dbh_t *dbh)
 {
-       pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
-
        PDO_DBG_ENTER("pdo_mysql_request_shutdown");
        PDO_DBG_INF_FMT("dbh=%p", dbh);
+
 #ifdef PDO_USE_MYSQLND
+       pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
        if (H->server) {
                mysqlnd_end_psession(H->server);
        }
@@ -634,7 +634,6 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
        /* handle MySQL options */
        if (driver_options) {
                zend_long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30);
-               unsigned int local_infile = (unsigned int) pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0);
                zend_string *init_cmd = NULL;
 #ifndef PDO_USE_MYSQLND
                zend_string *default_file = NULL, *default_group = NULL;
@@ -668,12 +667,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
                        goto cleanup;
                }
 
-#ifndef PDO_USE_MYSQLND
+#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
+               unsigned int local_infile = (unsigned int) pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0);
+# ifndef PDO_USE_MYSQLND
                if (PG(open_basedir) && PG(open_basedir)[0] != '\0') {
                        local_infile = 0;
                }
-#endif
-#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
+# endif
                if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
                        pdo_mysql_error(dbh);
                        goto cleanup;
index 3957a6c824fe86a76d8bde7b5e9388d73006a972..cfe1d68e495dee6f21b0d28cf51305805e81acc5 100644 (file)
@@ -123,7 +123,7 @@ typedef struct {
 #ifdef PDO_USE_MYSQLND
        const size_t                    *current_lengths;
 #else
-       zend_long                               *current_lengths;
+       unsigned long                   *current_lengths;
 #endif
        pdo_mysql_error_info    einfo;
 #ifdef PDO_USE_MYSQLND