From: Ilia Alshanetsky Date: Wed, 9 Feb 2005 16:33:00 +0000 (+0000) Subject: Fixed compile warnings. X-Git-Tag: RELEASE_0_2_1~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd6d5fb18fa1ede0acec6fda2f3f66670582887f;p=php Fixed compile warnings. --- diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index c51e68ad3d..4810cd0da3 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -166,8 +166,7 @@ static long pdo_sqlite_last_insert_id(pdo_dbh_t *dbh TSRMLS_DC) /* NB: doesn't handle binary strings... use prepared stmts for that */ static int sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC) { - pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data; - *quoted = emalloc(2*unquotedlen + 3); + *quoted = safe_emalloc(2, unquotedlen, 3); sqlite3_snprintf(2*unquotedlen + 3, *quoted, "'%q'", unquoted); *quotedlen = strlen(*quoted); return 1; @@ -217,8 +216,6 @@ static int sqlite_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) static int pdo_sqlite_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC) { - pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data; - switch (attr) { case PDO_ATTR_CLIENT_VERSION: case PDO_ATTR_SERVER_VERSION: @@ -242,6 +239,7 @@ static int pdo_sqlite_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) sqlite3_busy_timeout(H->db, Z_LVAL_P(val) * 1000); return 1; } + return 0; } static PHP_FUNCTION(sqlite_create_function) diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index 415f494f0c..38d091c9d7 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -34,7 +34,6 @@ static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) { pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; - int i; if (S->stmt) { sqlite3_finalize(S->stmt); @@ -46,18 +45,14 @@ static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) { - pdo_dbh_t *dbh = stmt->dbh; pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; - pdo_sqlite_db_handle *H = S->H; - int i; if (stmt->executed && !S->done) { sqlite3_reset(S->stmt); } S->done = 0; - i = sqlite3_step(S->stmt); - switch (i) { + switch (sqlite3_step(S->stmt)) { case SQLITE_ROW: S->pre_fetched = 1; stmt->column_count = sqlite3_data_count(S->stmt); @@ -81,10 +76,7 @@ static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC) { - pdo_dbh_t *dbh = stmt->dbh; pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; - pdo_sqlite_db_handle *H = S->H; - int i; switch (event_type) { case PDO_PARAM_EVT_EXEC_PRE: @@ -105,25 +97,27 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d return 0; case PDO_PARAM_NULL: - i = sqlite3_bind_null(S->stmt, param->paramno + 1); - if (i == SQLITE_OK) + if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { return 1; + } pdo_sqlite_error_stmt(stmt); return 0; case PDO_PARAM_STR: default: if (Z_TYPE_P(param->parameter) == IS_NULL) { - i = sqlite3_bind_null(S->stmt, param->paramno + 1); + if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { + return 1; + } } else { convert_to_string(param->parameter); - i = sqlite3_bind_text(S->stmt, param->paramno + 1, + if(SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter), - SQLITE_STATIC); + SQLITE_STATIC)) { + return 1; + } } - if (i == SQLITE_OK) - return 1; pdo_sqlite_error_stmt(stmt); return 0; }