Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cppcheck find bug #290

Open
RekGRpth opened this issue Nov 10, 2021 · 3 comments
Open

cppcheck find bug #290

RekGRpth opened this issue Nov 10, 2021 · 3 comments
Assignees

Comments

@RekGRpth
Copy link

lib/repack.c:947:26: style: Condition 'reltoastrelid1!=InvalidOid' is always true [knownConditionTrueFalse]
 else if (reltoastrelid1 != InvalidOid)
                         ^
@RekGRpth
Copy link
Author

and

bin/pg_repack.c:864:4: portability: %zi in format string (no. 2) requires 'size_t' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint]
   snprintf(errbuf, errsize,
   ^

@MichaelDBA
Copy link
Collaborator

Please specify OS, PG version, pg_repack version. Also that last conditional branch acts like an intended ELSE condition. Do you see something wrong with that?

@RekGRpth
Copy link
Author

today command

cppcheck -j"$(nproc)" --verbose --force --enable=all --suppress=variableScope .

gives

bin/pgut/pgut.c:1213:38: style: Parameter 'callback' can be declared with const [constParameter]
pgut_atexit_pop(pgut_atexit_callback callback, void *userdata)
                                     ^
bin/pgut/pgut.c:1213:54: style: Parameter 'userdata' can be declared with const [constParameter]
pgut_atexit_pop(pgut_atexit_callback callback, void *userdata)
                                                     ^
Checking bin/pgut/pgut.c: HAVE_LONG_INT_64...
bin/pgut/pgut-fe.c:309:13: style: Variable 'message' is assigned a value that is never used. [unreadVariable]
    message = "a List";
            ^
Checking bin/pgut/pgut-fe.c: HAVE_GETOPT_H...
lib/repack.c:950:26: style: Expression is always true because 'else if' condition is opposite to previous condition at line 925. [multiCondition]
 else if (reltoastrelid1 != InvalidOid)
                         ^
lib/repack.c:925:21: note: first condition
 if (reltoastrelid1 == InvalidOid)
                    ^
lib/repack.c:950:26: note: else if condition is opposite to first condition
 else if (reltoastrelid1 != InvalidOid)
                         ^
lib/repack.c:581:5: warning: Either the condition '(sql=strchr(sql,'('))==NULL' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck]
 sql++;
    ^
lib/repack.c:579:31: note: Assuming that condition '(sql=strchr(sql,'('))==NULL' is not redundant
 if ((sql = strchr(sql, '(')) == NULL)
                              ^
lib/repack.c:581:5: note: Null pointer addition
 sql++;
    ^
lib/repack.c:1092:3: style: Variable 'numobj' is assigned a value that is never used. [unreadVariable]
  --numobj;
  ^
lib/repack.c:141:0: information: Skipping configuration 'REPACK_VERSION' since the value of 'REPACK_VERSION' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. [ConfigurationNotChecked]
 return CStringGetTextDatum("pg_repack " LIBRARY_VERSION);
^
bin/pg_repack.c:869:4: portability: %zi in format string (no. 2) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint]
   snprintf(errbuf, errsize,
   ^
bin/pg_repack.c:932:14: style: Variable 'tablespace' is reassigned a value before the old one has been used. [redundantAssignment]
  tablespace = getstr(res, i, c++);
             ^
bin/pg_repack.c:919:14: note: tablespace is assigned
  tablespace = getstr(res, i, c++); /* to be clobbered */
             ^
bin/pg_repack.c:932:14: note: tablespace is overwritten
  tablespace = getstr(res, i, c++);
             ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants