You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2008/06/05 00:32:33 UTC

svn commit: r663393 - /apr/apr-util/trunk/dbd/apr_dbd_mysql.c

Author: bojan
Date: Wed Jun  4 15:32:33 2008
New Revision: 663393

URL: http://svn.apache.org/viewvc?rev=663393&view=rev
Log:
Use explicit casts to avoid compiler warnings on Windows.
Cannot use long long, it is not portable.

Modified:
    apr/apr-util/trunk/dbd/apr_dbd_mysql.c

Modified: apr/apr-util/trunk/dbd/apr_dbd_mysql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_mysql.c?rev=663393&r1=663392&r2=663393&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_mysql.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_mysql.c Wed Jun  4 15:32:33 2008
@@ -139,7 +139,8 @@
 
     /* fetch from offset if not at the beginning */
     if (boffset > 0) {
-        rv = mysql_stmt_fetch_column(res->statement, bind, col, boffset);
+        rv = mysql_stmt_fetch_column(res->statement, bind, col,
+                                     (unsigned long) boffset);
         if (rv != 0) {
             return APR_EGENERAL;
         }
@@ -253,7 +254,7 @@
 
 static const char *dbd_mysql_get_name(const apr_dbd_results_t *res, int n)
 {
-    if ((n < 0) || (n >= mysql_num_fields(res->res))) {
+    if ((n < 0) || (n >= (int) mysql_num_fields(res->res))) {
         return NULL;
     }
 
@@ -413,7 +414,7 @@
             *(apr_uint64_t*)data = apr_atoi64(bind->buffer);
             break;
         case APR_DBD_TYPE_FLOAT:
-            *(float*)data = atof(bind->buffer);
+            *(float*)data = (float) atof(bind->buffer);
             break;
         case APR_DBD_TYPE_DOUBLE:
             *(double*)data = atof(bind->buffer);
@@ -483,7 +484,7 @@
             *(apr_uint64_t*)data = apr_atoi64(row->row[n]);
             break;
         case APR_DBD_TYPE_FLOAT:
-            *(float*)data = atof(row->row[n]);
+            *(float*)data = (float) atof(row->row[n]);
             break;
         case APR_DBD_TYPE_DOUBLE:
             *(double*)data = atof(row->row[n]);
@@ -533,7 +534,7 @@
     if (ret != 0) {
         ret = mysql_errno(sql->conn);
     }
-    *nrows = mysql_affected_rows(sql->conn);
+    *nrows = (int) mysql_affected_rows(sql->conn);
     if (TXN_NOTICE_ERRORS(sql->trans)) {
         sql->trans->errnum = ret;
     }
@@ -639,7 +640,7 @@
         if (ret != 0) {
             ret = mysql_stmt_errno(statement->stmt);
         }
-        *nrows = mysql_stmt_affected_rows(statement->stmt);
+        *nrows = (int) mysql_stmt_affected_rows(statement->stmt);
     }
 
     return ret;
@@ -865,25 +866,28 @@
             bind[i].is_unsigned = 1;
             break;
         case APR_DBD_TYPE_LONGLONG:
-            if (sizeof(long long) == sizeof(apr_int64_t)) {
+            if (sizeof(my_ulonglong) == sizeof(apr_int64_t)) {
                 bind[i].buffer = arg;
+                bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
             }
-            else {
-                bind[i].buffer = apr_palloc(pool, sizeof(long long));
-                *(long long*)bind[i].buffer = *(apr_int64_t*)arg;
+            else { /* have to downsize, long long is not portable */
+                bind[i].buffer = apr_palloc(pool, sizeof(long));
+                *(long*)bind[i].buffer = (long) *(apr_int64_t*)arg;
+                bind[i].buffer_type = MYSQL_TYPE_LONG;
             }
-            bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
             bind[i].is_unsigned = 0;
             break;
         case APR_DBD_TYPE_ULONGLONG:
-            if (sizeof(unsigned long long) == sizeof(apr_uint64_t)) {
+            if (sizeof(my_ulonglong) == sizeof(apr_uint64_t)) {
                 bind[i].buffer = arg;
+                bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
             }
-            else {
-                bind[i].buffer = apr_palloc(pool, sizeof(unsigned long long));
-                *(unsigned long long*)bind[i].buffer = *(apr_uint64_t*)arg;
+            else { /* have to downsize, long long is not portable */
+                bind[i].buffer = apr_palloc(pool, sizeof(long));
+                *(unsigned long*)bind[i].buffer =
+                    (unsigned long) *(apr_uint64_t*)arg;
+                bind[i].buffer_type = MYSQL_TYPE_LONG;
             }
-            bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
             bind[i].is_unsigned = 1;
             break;
         case APR_DBD_TYPE_FLOAT: