Skip to content

Commit

Permalink
Fix signed/unsigned warnings in PDO ODBC
Browse files Browse the repository at this point in the history
Add add skipif to test.
  • Loading branch information
nikic committed Dec 14, 2020
1 parent 2b7eb0e commit aa58db7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
20 changes: 10 additions & 10 deletions ext/pdo_odbc/odbc_driver.c
Expand Up @@ -41,7 +41,7 @@ static int pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *inf

message = strpprintf(0, "%s (%s[%ld] at %s:%d)",
einfo->last_err_msg,
einfo->what, einfo->last_error,
einfo->what, (long) einfo->last_error,
einfo->file, einfo->line);

add_next_index_long(info, einfo->last_error);
Expand Down Expand Up @@ -85,8 +85,8 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
eh = H->env;
}

rc = SQLGetDiagRec(htype, eh, recno++, einfo->last_state, &einfo->last_error,
einfo->last_err_msg, sizeof(einfo->last_err_msg)-1, &errmsgsize);
rc = SQLGetDiagRec(htype, eh, recno++, (SQLCHAR *) einfo->last_state, &einfo->last_error,
(SQLCHAR *) einfo->last_err_msg, sizeof(einfo->last_err_msg)-1, &errmsgsize);

if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
errmsgsize = 0;
Expand All @@ -110,8 +110,8 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
* diagnostic records (which can be generated by PRINT statements
* in the query, for instance). */
while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
char discard_state[6];
char discard_buf[1024];
SQLCHAR discard_state[6];
SQLCHAR discard_buf[1024];
SQLINTEGER code;
rc = SQLGetDiagRec(htype, eh, recno++, discard_state, &code,
discard_buf, sizeof(discard_buf)-1, &errmsgsize);
Expand Down Expand Up @@ -192,7 +192,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
}
}

rc = SQLPrepare(S->stmt, (char*)sql, SQL_NTS);
rc = SQLPrepare(S->stmt, (SQLCHAR *) sql, SQL_NTS);
if (nsql) {
efree(nsql);
}
Expand Down Expand Up @@ -230,7 +230,7 @@ static zend_long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_le
return -1;
}

rc = SQLExecDirect(stmt, (char *)sql, sql_len);
rc = SQLExecDirect(stmt, (SQLCHAR *) sql, sql_len);

if (rc == SQL_NO_DATA) {
/* If SQLExecDirect executes a searched update or delete statement that
Expand Down Expand Up @@ -442,7 +442,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
}

if (strchr(dbh->data_source, ';')) {
char dsnbuf[1024];
SQLCHAR dsnbuf[1024];
SQLSMALLINT dsnbuflen;

use_direct = 1;
Expand All @@ -456,11 +456,11 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
dbh->data_source = dsn;
}

rc = SQLDriverConnect(H->dbc, NULL, (char*)dbh->data_source, strlen(dbh->data_source),
rc = SQLDriverConnect(H->dbc, NULL, (SQLCHAR *) dbh->data_source, strlen(dbh->data_source),
dsnbuf, sizeof(dsnbuf)-1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
}
if (!use_direct) {
rc = SQLConnect(H->dbc, (char*)dbh->data_source, SQL_NTS, dbh->username, SQL_NTS, dbh->password, SQL_NTS);
rc = SQLConnect(H->dbc, (SQLCHAR *) dbh->data_source, SQL_NTS, (SQLCHAR *) dbh->username, SQL_NTS, (SQLCHAR *) dbh->password, SQL_NTS);
}

if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
Expand Down
6 changes: 3 additions & 3 deletions ext/pdo_odbc/odbc_stmt.c
Expand Up @@ -567,7 +567,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno)
SQLULEN colsize;
SQLLEN displaysize = 0;

rc = SQLDescribeCol(S->stmt, colno+1, S->cols[colno].colname,
rc = SQLDescribeCol(S->stmt, colno+1, (SQLCHAR *) S->cols[colno].colname,
sizeof(S->cols[colno].colname)-1, &colnamelen,
&S->cols[colno].coltype, &colsize, NULL, NULL);

Expand Down Expand Up @@ -777,7 +777,7 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, zend_long attr, zval *val)
switch (attr) {
case PDO_ATTR_CURSOR_NAME:
convert_to_string(val);
rc = SQLSetCursorName(S->stmt, Z_STRVAL_P(val), Z_STRLEN_P(val));
rc = SQLSetCursorName(S->stmt, (SQLCHAR *) Z_STRVAL_P(val), Z_STRLEN_P(val));

if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
return 1;
Expand Down Expand Up @@ -806,7 +806,7 @@ static int odbc_stmt_get_attr(pdo_stmt_t *stmt, zend_long attr, zval *val)
{
char buf[256];
SQLSMALLINT len = 0;
rc = SQLGetCursorName(S->stmt, buf, sizeof(buf), &len);
rc = SQLGetCursorName(S->stmt, (SQLCHAR *) buf, sizeof(buf), &len);

if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
ZVAL_STRINGL(val, buf, len);
Expand Down
2 changes: 2 additions & 0 deletions ext/pdo_odbc/tests/max_columns.phpt
Expand Up @@ -3,6 +3,8 @@ PDO ODBC varying character with max/no length
--SKIPIF--
<?php
if (!extension_loaded('pdo_odbc')) print 'skip not loaded';
require 'ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
Expand Down

0 comments on commit aa58db7

Please sign in to comment.