EnterpriseDB / pldebugger

Procedural Language Debugger Plugin for PostgreSQL and EDB Postgres Advanced Server
70 stars 19 forks source link

cppcheck find bug #4

Open RekGRpth opened 2 years ago

RekGRpth commented 2 years ago
plpgsql_debugger.c:1119:7: style: Condition 'target' is always true [knownConditionTrueFalse]
  if( target )
      ^
plpgsql_debugger.c:1077:6: note: Assuming that condition '!target' is not redundant
 if (!target)
     ^
plpgsql_debugger.c:1119:7: note: Condition 'target' is always true
  if( target )
      ^
RekGRpth commented 2 years ago

and

plpgsql_debugger.c:1270:11: style: Local variable 'i' shadows outer variable [shadowVariable]
   int    i;
          ^
plpgsql_debugger.c:1246:11: note: Shadowed declaration
  int     i;
          ^
plpgsql_debugger.c:1270:11: note: Shadow variable
   int    i;
          ^

that solve by

diff --git a/plpgsql_debugger.c b/plpgsql_debugger.c
index 6812592..872355c 100644
--- a/plpgsql_debugger.c
+++ b/plpgsql_debugger.c
@@ -1267,8 +1267,6 @@ is_datum_visible(PLpgSQL_datum *datum)

                if( strncmp( var->refname, "txt", 3 ) == 0 )
                {
-                       int        i;
-
                        /*
                         * Starts with 'txt' - see if the rest of the string is composed
                         * entirely of digits
RekGRpth commented 2 years ago

and

pldbgapi.c:1195:5: style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]
    break;
    ^

tha solve by

diff --git a/pldbgapi.c b/pldbgapi.c
index 3a05260..7aff673 100644
--- a/pldbgapi.c
+++ b/pldbgapi.c
@@ -1192,7 +1192,6 @@ static void * readn( int serverHandle, void * dst, size_t len )
                        {
                                /* Timer expired */
                                return( NULL );
-                               break;
                        }

                        default: