From ec9f55293663741d39d510cffd306310ce4ea054 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 25 Jul 2018 10:34:13 -0700 Subject: [PATCH] Fixed formattings and clean up --- source/pdo_sqlsrv/pdo_util.cpp | 2 +- source/shared/core_sqlsrv.h | 9 ++++----- source/shared/core_util.cpp | 6 +++--- source/sqlsrv/stmt.cpp | 5 ++--- source/sqlsrv/util.cpp | 11 +++-------- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index dffe53c3a..1a16ab4c6 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -512,7 +512,7 @@ bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned msg = static_cast( sqlsrv_malloc( msg_len ) ); core_sqlsrv_format_message( msg, static_cast( msg_len ), WARNING_TEMPLATE, error->sqlstate, error->native_code, error->native_message ); - php_error( E_WARNING, "%s", msg.get() ); + php_error(E_WARNING, "%s", msg.get()); } ctx.set_last_error( error ); break; diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 823b35dcd..d630fb478 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -693,9 +693,9 @@ class hash_auto_ptr : public sqlsrv_auto_ptr { // free the original pointer and assign a new pointer. Use NULL to simply free the pointer. void reset( _In_opt_ HashTable* ptr = NULL ) { - if( _ptr != NULL ) { - zend_hash_destroy( _ptr ); - FREE_HASHTABLE( _ptr ); + if (_ptr != NULL) { + zend_hash_destroy(_ptr); + FREE_HASHTABLE(_ptr); } _ptr = ptr; } @@ -2378,8 +2378,7 @@ namespace core { inline void sqlsrv_array_init( _Inout_ sqlsrv_context& ctx, _Out_ zval* new_array TSRMLS_DC) { #if PHP_VERSION_ID < 70300 - int zr = ::array_init(new_array); - CHECK_ZEND_ERROR(zr, ctx, SQLSRV_ERROR_ZEND_HASH) { + CHECK_ZEND_ERROR(::array_init(new_array), ctx, SQLSRV_ERROR_ZEND_HASH) { throw CoreException(); } #else diff --git a/source/shared/core_util.cpp b/source/shared/core_util.cpp index 5d943fabb..38940e085 100644 --- a/source/shared/core_util.cpp +++ b/source/shared/core_util.cpp @@ -352,11 +352,11 @@ void die( _In_opt_ const char* msg, ... ) va_start( format_args, msg ); DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, msg, 0, 0, last_err_msg, sizeof( last_err_msg ), &format_args ); va_end( format_args ); - if( rc == 0 ) { - php_error( E_ERROR, "%s", reinterpret_cast( INTERNAL_FORMAT_ERROR )); + if (rc == 0) { + php_error(E_ERROR, "%s", reinterpret_cast(INTERNAL_FORMAT_ERROR)); } - php_error( E_ERROR, "%s", last_err_msg ); + php_error(E_ERROR, "%s", last_err_msg); } namespace { diff --git a/source/sqlsrv/stmt.cpp b/source/sqlsrv/stmt.cpp index 2f1291ba7..712f48d4b 100644 --- a/source/sqlsrv/stmt.cpp +++ b/source/sqlsrv/stmt.cpp @@ -1808,10 +1808,9 @@ void fetch_fields_common( _Inout_ ss_sqlsrv_stmt* stmt, _In_ zend_long fetch_typ field_names.transferred(); } - int zr; + int zr = SUCCESS; #if PHP_VERSION_ID < 70300 - zr = array_init(&fields); - CHECK_ZEND_ERROR(zr, stmt, SQLSRV_ERROR_ZEND_HASH) { + CHECK_ZEND_ERROR(array_init(&fields), stmt, SQLSRV_ERROR_ZEND_HASH) { throw ss::SSException(); } #else diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index a42fa36b2..7b35dbd92 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -503,12 +503,10 @@ PHP_FUNCTION( sqlsrv_errors ) LOG( SEV_ERROR, "An invalid parameter was passed to %1!s!.", _FN_ ); RETURN_FALSE; } - int result; zval err_z; ZVAL_UNDEF(&err_z); #if PHP_VERSION_ID < 70300 - result = array_init(&err_z); - if (result == FAILURE) { + if (array_init(&err_z) == FAILURE) { RETURN_FALSE; } #else @@ -836,7 +834,6 @@ bool handle_errors_and_warnings( _Inout_ sqlsrv_context& ctx, _Inout_ zval* repo size_t prev_reported_cnt = 0; bool reported_chain_was_null = false; bool ignored_chain_was_null = false; - int zr = SUCCESS; zval error_z; ZVAL_UNDEF(&error_z); sqlsrv_error_auto_ptr error; @@ -846,8 +843,7 @@ bool handle_errors_and_warnings( _Inout_ sqlsrv_context& ctx, _Inout_ zval* repo reported_chain_was_null = true; #if PHP_VERSION_ID < 70300 - zr = array_init(reported_chain); - if (zr == FAILURE) { + if (array_init(reported_chain) == FAILURE) { DIE( "Fatal error during error processing" ); } #else @@ -865,8 +861,7 @@ bool handle_errors_and_warnings( _Inout_ sqlsrv_context& ctx, _Inout_ zval* repo ignored_chain_was_null = true; #if PHP_VERSION_ID < 70300 - zr = array_init(ignored_chain); - if (zr == FAILURE) { + if (array_init(ignored_chain) == FAILURE) { DIE( "Fatal error in handle_errors_and_warnings" ); } #else