]> granicus.if.org Git - php/commitdiff
Fix Windows compilation warnings (Senthil)
authorChristopher Jones <christopher.jones@oracle.com>
Mon, 29 Jun 2015 22:48:37 +0000 (08:48 +1000)
committerChristopher Jones <christopher.jones@oracle.com>
Mon, 29 Jun 2015 22:48:37 +0000 (08:48 +1000)
ext/pdo_oci/oci_driver.c
ext/pdo_oci/oci_statement.c

index c7658477aa976925981af89f1d4af77087c76d5e..25515544769477c5672d162d2b0dd87e283d8b3f 100644 (file)
@@ -287,7 +287,7 @@ static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
        OCIHandleAlloc(H->env, (dvoid*)&S->err, OCI_HTYPE_ERROR, 0, NULL);
 
        if (sql_len) {
-               H->last_err = OCIStmtPrepare(S->stmt, H->err, (text*)sql, sql_len, OCI_NTV_SYNTAX, OCI_DEFAULT);
+               H->last_err = OCIStmtPrepare(S->stmt, H->err, (text*)sql, (ub4) sql_len, OCI_NTV_SYNTAX, OCI_DEFAULT);
                if (nsql) {
                        efree(nsql);
                        nsql = NULL;
@@ -302,7 +302,7 @@ static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
 
        }
 
-       prefetch = pdo_oci_sanitize_prefetch(pdo_attr_lval(driver_options, PDO_ATTR_PREFETCH, PDO_OCI_PREFETCH_DEFAULT));
+       prefetch = pdo_oci_sanitize_prefetch((long) pdo_attr_lval(driver_options, PDO_ATTR_PREFETCH, PDO_OCI_PREFETCH_DEFAULT));
        if (prefetch) {
                H->last_err = OCIAttrSet(S->stmt, OCI_HTYPE_STMT, &prefetch, 0,
                        OCI_ATTR_PREFETCH_ROWS, H->err);
@@ -334,7 +334,7 @@ static zend_long oci_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len
 
        OCIHandleAlloc(H->env, (dvoid*)&stmt, OCI_HTYPE_STMT, 0, NULL);
 
-       H->last_err = OCIStmtPrepare(stmt, H->err, (text*)sql, sql_len, OCI_NTV_SYNTAX, OCI_DEFAULT);
+       H->last_err = OCIStmtPrepare(stmt, H->err, (text*)sql, (ub4) sql_len, OCI_NTV_SYNTAX, OCI_DEFAULT);
        if (H->last_err) {
                H->last_err = oci_drv_error("OCIStmtPrepare");
                OCIHandleFree(stmt, OCI_HTYPE_STMT);
@@ -458,7 +458,7 @@ static int oci_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /
 
                convert_to_long(val);
 
-               dbh->auto_commit = Z_LVAL_P(val);
+               dbh->auto_commit = (unsigned int) (Z_LVAL_P(val)) ? 1 : 0;
                return 1;
        } else {
                return 0;
@@ -629,7 +629,7 @@ static int pdo_oci_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ *
        OCIHandleAlloc(H->env, (dvoid **)&H->server, OCI_HTYPE_SERVER, 0, NULL);
 
        H->last_err = OCIServerAttach(H->server, H->err, (text*)vars[1].optval,
-                       strlen(vars[1].optval), OCI_DEFAULT);
+                       (sb4) strlen(vars[1].optval), OCI_DEFAULT);
 
        if (H->last_err) {
                oci_drv_error("pdo_oci_handle_factory");
@@ -661,7 +661,7 @@ static int pdo_oci_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ *
        /* username */
        if (dbh->username) {
                H->last_err = OCIAttrSet(H->session, OCI_HTYPE_SESSION,
-                               dbh->username, strlen(dbh->username),
+                               dbh->username, (ub4) strlen(dbh->username),
                                OCI_ATTR_USERNAME, H->err);
                if (H->last_err) {
                        oci_drv_error("OCIAttrSet: OCI_ATTR_USERNAME");
@@ -672,7 +672,7 @@ static int pdo_oci_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ *
        /* password */
        if (dbh->password) {
                H->last_err = OCIAttrSet(H->session, OCI_HTYPE_SESSION,
-                               dbh->password, strlen(dbh->password),
+                               dbh->password, (ub4) strlen(dbh->password),
                                OCI_ATTR_PASSWORD, H->err);
                if (H->last_err) {
                        oci_drv_error("OCIAttrSet: OCI_ATTR_PASSWORD");
index bf0a1b4b44801419d80c022181b1df74d64b35c1..3148162d61ab210f5780ad73dec50f0f0402c04a 100644 (file)
@@ -214,7 +214,7 @@ static sb4 oci_bind_input_cb(dvoid *ctx, OCIBind *bindp, ub4 iter, ub4 index, dv
                /* regular string bind */
                convert_to_string(parameter);
                *bufpp = Z_STRVAL_P(parameter);
-               *alenp = Z_STRLEN_P(parameter);
+               *alenp = (ub4) Z_STRLEN_P(parameter);
        }
 
        *piecep = OCI_ONE_PIECE;
@@ -258,7 +258,7 @@ static sb4 oci_bind_output_cb(dvoid *ctx, OCIBind *bindp, ub4 iter, ub4 index, d
        Z_STR_P(parameter) = ecalloc(1, Z_STRLEN_P(parameter)+1);
        P->used_for_output = 1;
 
-       P->actual_len = Z_STRLEN_P(parameter);
+       P->actual_len = (ub4) Z_STRLEN_P(parameter);
        *alenpp = &P->actual_len;
        *bufpp = Z_STRVAL_P(parameter);
        *piecep = OCI_ONE_PIECE;
@@ -311,15 +311,15 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
                                        case PDO_PARAM_LOB:
                                                /* P->thing is now an OCILobLocator * */
                                                P->oci_type = SQLT_BLOB;
-                                               value_sz = sizeof(OCILobLocator*);
+                                               value_sz = (sb4) sizeof(OCILobLocator*);
                                                break;
 
                                        case PDO_PARAM_STR:
                                        default:
                                                P->oci_type = SQLT_CHR;
-                                               value_sz = param->max_value_len;
+                                               value_sz = (sb4) param->max_value_len;
                                                if (param->max_value_len == 0) {
-                                                       value_sz = 1332; /* maximum size before value is interpreted as a LONG value */
+                                                       value_sz = (sb4) 1332; /* maximum size before value is interpreted as a LONG value */
                                                }
 
                                }
@@ -327,12 +327,12 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
                                if (param->name) {
                                        STMT_CALL(OCIBindByName, (S->stmt,
                                                        &P->bind, S->err, (text*)param->name->val,
-                                                       param->name->len, 0, value_sz, P->oci_type,
+                                                       (sb4) param->name->len, 0, value_sz, P->oci_type,
                                                        &P->indicator, 0, &P->retcode, 0, 0,
                                                        OCI_DATA_AT_EXEC));
                                } else {
                                        STMT_CALL(OCIBindByPos, (S->stmt,
-                                                       &P->bind, S->err, param->paramno+1,
+                                                       &P->bind, S->err, ((ub4)param->paramno)+1,
                                                        0, value_sz, P->oci_type,
                                                        &P->indicator, 0, &P->retcode, 0, 0,
                                                        OCI_DATA_AT_EXEC));
@@ -403,9 +403,9 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
                                                                }
                                                                consume = buf;
                                                                do {
-                                                                       amt = n;
+                                                                       amt = (ub4) n;
                                                                        OCILobWrite(S->H->svc, S->err, (OCILobLocator*)P->thing,
-                                                                                       &amt, offset, consume, n,
+                                                                                       &amt, offset, consume, (ub4) n,
                                                                                        OCI_ONE_PIECE,
                                                                                        NULL, NULL, 0, SQLCS_IMPLICIT);
                                                                        offset += amt;
@@ -422,9 +422,9 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
                                                        if (n) {
                                                                OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE);
                                                                while (n) {
-                                                                       amt = n;
+                                                                       amt = (ub4) n;
                                                                        OCILobWrite(S->H->svc, S->err, (OCILobLocator*)P->thing,
-                                                                                       &amt, offset, consume, n,
+                                                                                       &amt, offset, consume, (ub4) n,
                                                                                        OCI_ONE_PIECE,
                                                                                        NULL, NULL, 0, SQLCS_IMPLICIT);
                                                                        consume += amt;
@@ -461,7 +461,7 @@ static int oci_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend
                case PDO_FETCH_ORI_ABS:         ociori = OCI_FETCH_ABSOLUTE; break;
                case PDO_FETCH_ORI_REL:         ociori = OCI_FETCH_RELATIVE; break;
        }
-       S->last_err = OCIStmtFetch2(S->stmt, S->err, 1, ociori, offset, OCI_DEFAULT);
+       S->last_err = OCIStmtFetch2(S->stmt, S->err, 1, ociori, (sb4) offset, OCI_DEFAULT);
 #else
        S->last_err = OCIStmtFetch(S->stmt, S->err, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
 #endif
@@ -586,7 +586,7 @@ static int oci_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
                                S->cols[colno].datalen = 1024;
 #endif
                        } else {
-                               S->cols[colno].datalen = col->maxlen;
+                               S->cols[colno].datalen = (ub4) col->maxlen;
                        }
                        if (dtype == SQLT_BIN) {
                                S->cols[colno].datalen *= 3;
@@ -623,9 +623,9 @@ static size_t oci_blob_write(php_stream *stream, const char *buf, size_t count)
        ub4 amt;
        sword r;
 
-       amt = count;
+       amt = (ub4) count;
        r = OCILobWrite(self->S->H->svc, self->S->err, self->lob,
-               &amt, self->offset, (char*)buf, count,
+               &amt, self->offset, (char*)buf, (ub4) count,
                OCI_ONE_PIECE,
                NULL, NULL, 0, SQLCS_IMPLICIT);
 
@@ -643,9 +643,9 @@ static size_t oci_blob_read(php_stream *stream, char *buf, size_t count)
        ub4 amt;
        sword r;
 
-       amt = count;
+       amt = (ub4) count;
        r = OCILobRead(self->S->H->svc, self->S->err, self->lob,
-               &amt, self->offset, buf, count,
+               &amt, self->offset, buf, (ub4) count,
                NULL, NULL, 0, SQLCS_IMPLICIT);
 
        if (r != OCI_SUCCESS && r != OCI_NEED_DATA) {
@@ -661,8 +661,8 @@ static size_t oci_blob_read(php_stream *stream, char *buf, size_t count)
 
 static int oci_blob_close(php_stream *stream, int close_handle)
 {
-       struct oci_lob_self *self = (struct oci_lob_self*)stream->abstract;
-       pdo_stmt_t *stmt = self->stmt;
+       struct oci_lob_self *self = (struct oci_lob_self *)stream->abstract;
+       /* pdo_stmt_t *stmt = self->stmt; */
 
        if (close_handle) {
                OCILobClose(self->S->H->svc, self->S->err, self->lob);
@@ -680,14 +680,14 @@ static int oci_blob_flush(php_stream *stream)
        return 0;
 }
 
-static int oci_blob_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset)
+static int oci_blob_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset)
 {
        struct oci_lob_self *self = (struct oci_lob_self*)stream->abstract;
 
        if (offset >= PDO_OCI_LOBMAXSIZE) {
                return -1;
        } else {
-               self->offset = offset + 1;  /* Oracle LOBS are 1-based, but PHP is 0-based */
+               self->offset = (ub4) offset + 1;  /* Oracle LOBS are 1-based, but PHP is 0-based */
                return 0;
        }
 }
@@ -723,7 +723,7 @@ static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob)
        return NULL;
 }
 
-static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees) /* {{{ */
+static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len, int *caller_frees) /* {{{ */
 {
        pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data;
        pdo_oci_column *C = &S->cols[colno];
@@ -742,19 +742,19 @@ static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned lo
                                *ptr = (char*)oci_create_lob_stream(stmt, (OCILobLocator*)C->data);
                                OCILobOpen(S->H->svc, S->err, (OCILobLocator*)C->data, OCI_LOB_READONLY);
                        }
-                       *len = 0;
+                       *len = (size_t) 0;
                        return *ptr ? 1 : 0;
                }
 
                *ptr = C->data;
-               *len = C->fetched_len;
+               *len = (size_t) C->fetched_len;
                return 1;
        } else {
                /* it was truncated */
                php_error_docref(NULL, E_WARNING, "column %d data was too large for buffer and was truncated to fit it", colno);
 
                *ptr = C->data;
-               *len = C->fetched_len;
+               *len = (size_t) C->fetched_len;
                return 1;
        }
 } /* }}} */