Skip to content

Commit

Permalink
cleanup redundant conditions (#184)
Browse files Browse the repository at this point in the history
* cleanup: remove redundant condition

DriverManager/SQLGetConnectOption.c:368:30: style: Condition 'value' is always true [knownConditionTrueFalse]

* cleanup: remove redundant condition

DriverManager/SQLGetDiagRec.c:416:22: style: Condition 'sqlstate' is always true [knownConditionTrueFalse]

* cleanup: remove redundant condition

* cleanup: remove dead code

DriverManager/__stats.c:544:9: style: Condition '!sh' is always false [knownConditionTrueFalse]
  • Loading branch information
chipitsine authored Oct 6, 2024
1 parent 93ec2f0 commit 4c8b9e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
10 changes: 1 addition & 9 deletions DriverManager/SQLGetConnectOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,7 @@ SQLRETURN SQLGetConnectOption( SQLHDBC connection_handle,
case SQL_ATTR_TRACEFILE:
case SQL_ATTR_TRANSLATE_LIB:
if ( SQL_SUCCEEDED( ret ) && value )
{
/*
* guess a length
*/
if ( value )
{
s1 = malloc( sizeof( SQLWCHAR ) * 1024 );
}
}
s1 = malloc( sizeof( SQLWCHAR ) * 1024 ); /* guess a length */
break;
}

Expand Down
7 changes: 2 additions & 5 deletions DriverManager/SQLGetDiagRec.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,8 @@ static SQLRETURN extract_sql_error_rec( EHEAD *head,

if ( SQL_SUCCEEDED( ret ) && sqlstate )
{
if ( sqlstate )
{
unicode_to_ansi_copy((char*) sqlstate, 6, s1, SQL_NTS, __get_connection( head ), NULL );
__map_error_state((char*) sqlstate, __get_version( head ));
}
unicode_to_ansi_copy((char*) sqlstate, 6, s1, SQL_NTS, __get_connection( head ), NULL );
__map_error_state((char*) sqlstate, __get_version( head ));
if ( message_text )
{
unicode_to_ansi_copy((char*) message_text, buffer_length, s2, SQL_NTS, __get_connection( head ), NULL );
Expand Down
9 changes: 3 additions & 6 deletions DriverManager/SQLGetDiagRecW.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,10 @@ static SQLRETURN extract_sql_error_rec_w( EHEAD *head,

if ( SQL_SUCCEEDED( ret ) && sqlstate )
{
if ( sqlstate )
if ( as1 )
{
if ( as1 )
{
ansi_to_unicode_copy( sqlstate,(char*) as1, SQL_NTS, __get_connection( head ), NULL );
__map_error_state_w( sqlstate, __get_version( head ));
}
ansi_to_unicode_copy( sqlstate,(char*) as1, SQL_NTS, __get_connection( head ), NULL );
__map_error_state_w( sqlstate, __get_version( head ));
}
if ( message_text )
{
Expand Down
5 changes: 0 additions & 5 deletions DriverManager/__stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,6 @@ int uodbc_get_stats(
snprintf(errmsg, sizeof(errmsg), "No stats return structures supplied");
return -1;
}
if (!sh)
{
snprintf(errmsg, sizeof(errmsg), "NULL stats handle");
return -1;
}
if (memcmp(sh->id, UODBC_STATS_ID, sizeof(sh->id)) != 0)
{
snprintf(errmsg, sizeof(errmsg), "Invalid stats handle %p", sh);
Expand Down

0 comments on commit 4c8b9e9

Please sign in to comment.