pldebugger icon indicating copy to clipboard operation
pldebugger copied to clipboard

cppcheck find bug

Open RekGRpth opened this issue 3 years ago • 2 comments

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 avatar Nov 10 '21 11:11 RekGRpth

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 avatar Nov 10 '21 11:11 RekGRpth

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:

RekGRpth avatar Nov 10 '21 11:11 RekGRpth