Skip to content

Commit

Permalink
Fixed formattings and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed Jul 25, 2018
1 parent 3bc302b commit ec9f552
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion source/pdo_sqlsrv/pdo_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ bool pdo_sqlsrv_handle_dbh_error( _Inout_ sqlsrv_context& ctx, _In_opt_ unsigned
msg = static_cast<char*>( sqlsrv_malloc( msg_len ) );
core_sqlsrv_format_message( msg, static_cast<unsigned int>( 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;
Expand Down
9 changes: 4 additions & 5 deletions source/shared/core_sqlsrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ class hash_auto_ptr : public sqlsrv_auto_ptr<HashTable, hash_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;
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions source/shared/core_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>( INTERNAL_FORMAT_ERROR ));
if (rc == 0) {
php_error(E_ERROR, "%s", reinterpret_cast<const char*>(INTERNAL_FORMAT_ERROR));
}

php_error( E_ERROR, "%s", last_err_msg );
php_error(E_ERROR, "%s", last_err_msg);
}

namespace {
Expand Down
5 changes: 2 additions & 3 deletions source/sqlsrv/stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions source/sqlsrv/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ec9f552

Please sign in to comment.