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

[Compute]: Warnings during the compilation #6188

Closed
vadim2404 opened this issue Dec 19, 2023 · 7 comments · Fixed by #7053
Closed

[Compute]: Warnings during the compilation #6188

vadim2404 opened this issue Dec 19, 2023 · 7 comments · Fixed by #7053
Assignees
Labels
c/compute Component: compute, excluding postgres itself t/bug Issue Type: Bug

Comments

@vadim2404
Copy link
Contributor

neon_utils.c:15:1: warning: no previous prototype for 'HexDecodeChar' [-Wmissing-prototypes]
   15 | HexDecodeChar(char c)
      | ^~~~~~~~~~~~~
neon_utils.c:33:1: warning: no previous prototype for 'HexDecodeString' [-Wmissing-prototypes]
   33 | HexDecodeString(uint8 *result, char *input, int nbytes)
      | ^~~~~~~~~~~~~~~
neon_utils.c:55:1: warning: no previous prototype for 'pq_getmsgint32_le' [-Wmissing-prototypes]
   55 | pq_getmsgint32_le(StringInfo msg)
      | ^~~~~~~~~~~~~~~~~
neon_utils.c:69:1: warning: no previous prototype for 'pq_getmsgint64_le' [-Wmissing-prototypes]
   69 | pq_getmsgint64_le(StringInfo msg)
      | ^~~~~~~~~~~~~~~~~
neon_utils.c:80:1: warning: no previous prototype for 'pq_sendint32_le' [-Wmissing-prototypes]
   80 | pq_sendint32_le(StringInfo buf, uint32 i)
      | ^~~~~~~~~~~~~~~
neon_utils.c:89:1: warning: no previous prototype for 'pq_sendint64_le' [-Wmissing-prototypes]
   89 | pq_sendint64_le(StringInfo buf, uint64 i)
      | ^~~~~~~~~~~~~~~
neon_utils.c:100:1: warning: no previous prototype for 'disable_core_dump' [-Wmissing-prototypes]
  100 | disable_core_dump()
      | ^~~~~~~~~~~~~~~~~
extension_server.c: In function 'neon_download_extension_file_http':
extension_server.c:37:11: warning: unused variable 'postdata' [-Wunused-variable]
   37 |  char    *postdata;
      |           ^~~~~~~~
extension_server.c: At top level:
extension_server.c:78:1: warning: no previous prototype for 'pg_init_extension_server' [-Wmissing-prototypes]
   78 | pg_init_extension_server()
      | ^~~~~~~~~~~~~~~~~~~~~~~~
control_plane_connector.c: In function 'ConstructDeltaMessage':
control_plane_connector.c:123:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  123 |   HASH_SEQ_STATUS status;
      |   ^~~~~~~~~~~~~~~
control_plane_connector.c:155:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  155 |   HASH_SEQ_STATUS status;
      |   ^~~~~~~~~~~~~~~
control_plane_connector.c:172:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  172 |     char    *encrypted_password = get_role_password(entry->name, &logdetail);
      |     ^~~~
control_plane_connector.c:191:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  191 |  JsonbValue *result = pushJsonbValue(&state, WJB_END_OBJECT, NULL);
      |  ^~~~~~~~~~
control_plane_connector.c: In function 'SendDeltasToControlPlane':
control_plane_connector.c:239:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  239 |  char    *message = ConstructDeltaMessage();
      |  ^~~~
walproposer_pg.c:391:1: warning: no previous prototype for 'replication_feedback_set' [-Wmissing-prototypes]
  391 | replication_feedback_set(PageserverFeedback *rf)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
walproposer.c: In function 'AdvancePollState':
walproposer.c:477:15: warning: unused variable 'wp' [-Wunused-variable]
  477 |  WalProposer *wp = sk->wp;
      |               ^~
walproposer_pg.c: In function 'StartProposerReplication':
walproposer_pg.c:975:13: warning: variable 'currTLI' set but not used [-Wunused-but-set-variable]
  975 |  TimeLineID currTLI;
      |             ^~~~~~~
walproposer.c: At top level:
walproposer.c:1490:1: warning: no previous prototype for 'ParsePageserverFeedbackMessage' [-Wmissing-prototypes]
 1490 | ParsePageserverFeedbackMessage(WalProposer *wp, StringInfo reply_message, PageserverFeedback *rf)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
control_plane_connector.c:251:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  251 |  const int num_retries = 5;
      |  ^~~~~
control_plane_connector.c: In function 'MergeTable':
control_plane_connector.c:350:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  350 |   DbEntry    *entry;
      |   ^~~~~~~
control_plane_connector.c:395:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  395 |   RoleEntry  *entry;
      |   ^~~~~~~~~
control_plane_connector.c: In function 'HandleCreateDb':
control_plane_connector.c:489:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  489 |  DefElem    *downer = NULL;
      |  ^~~~~~~
control_plane_connector.c:499:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  499 |  bool  found = false;
      |  ^~~~
control_plane_connector.c: In function 'HandleAlterOwner':
control_plane_connector.c:530:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  530 |  const char *name = strVal(stmt->object);
      |  ^~~~~
control_plane_connector.c:540:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  540 |  const char *new_owner = get_rolespec_name(stmt->newowner);
      |  ^~~~~
control_plane_connector.c: In function 'HandleDbRename':
control_plane_connector.c:553:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  553 |  bool  found = false;
      |  ^~~~
control_plane_connector.c: In function 'HandleDropDb':
control_plane_connector.c:590:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  590 |  bool  found = false;
      |  ^~~~
control_plane_connector.c: In function 'HandleCreateRole':
control_plane_connector.c:607:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  607 |  bool  found = false;
      |  ^~~~
control_plane_connector.c: In function 'HandleAlterRole':
control_plane_connector.c:636:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  636 |  DefElem    *dpass = NULL;
      |  ^~~~~~~
control_plane_connector.c:653:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  653 |  bool  found = false;
      |  ^~~~
control_plane_connector.c: In function 'HandleRoleRename':
control_plane_connector.c:[674](https://github.com/neondatabase/neon/actions/runs/7261297170/job/19782211123?pr=6184#step:5:675):2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  674 |  bool  found = false;
      |  ^~~~
control_plane_connector.c: In function 'HandleDropRole':
control_plane_connector.c:[712](https://github.com/neondatabase/neon/actions/runs/7261297170/job/19782211123?pr=6184#step:5:713):2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  712 |  ListCell   *item;
      |  ^~~~~~~~
control_plane_connector.c: At top level:
control_plane_connector.c:807:1: warning: no previous prototype for 'InitControlPlaneConnector' [-Wmissing-prototypes]
  807 | InitControlPlaneConnector()
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
control_plane_connector.c: In function 'InitControlPlaneConnector':
control_plane_connector.c:838:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  838 |  const char *jwt_token = getenv("NEON_CONTROL_PLANE_TOKEN");
      |  ^~~~~
file_cache.c: In function 'neon_get_lfc_stats':
file_cache.c:772:13: warning: 'value' may be used uninitialized in this function [-Wmaybe-uninitialized]
  772 |   values[1] = Int64GetDatum(value);
In file included from /usr/local/pgsql/include/server/postgres.h:47,
                 from hnsw.c:1:
hnsw.c: In function 'hnsw_check_available_memory':
hnsw.c:152:15: warning: format '%n' expects a matching 'int *' argument [-Wformat=]
  152 |   elog(ERROR, "Failed to get amount of RAM: %n");
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/pgsql/include/server/utils/elog.h:141:4: note: in definition of macro 'ereport_domain'
  141 |    __VA_ARGS__, errfinish(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \
      |    ^~~~~~~~~~~
/usr/local/pgsql/include/server/utils/elog.h:233:2: note: in expansion of macro 'ereport'
  233 |  ereport(elevel, errmsg_internal(__VA_ARGS__))
      |  ^~~~~~~
hnsw.c:152:3: note: in expansion of macro 'elog'
  152 |   elog(ERROR, "Failed to get amount of RAM: %n");
      |   ^~~~
hnsw.c:152:46: note: format string is defined here
  152 |   elog(ERROR, "Failed to get amount of RAM: %n");
      |                                             ~^
      |                                              |
      |                                              int *
@vadim2404 vadim2404 added t/bug Issue Type: Bug c/compute Component: compute, excluding postgres itself labels Dec 19, 2023
@skyzh skyzh self-assigned this Feb 27, 2024
@skyzh
Copy link
Member

skyzh commented Feb 28, 2024

It seems that these warnings cannot be reproduced on the dev server. So I guess it's specific to a compiler version when building our compute node image.

@skyzh
Copy link
Member

skyzh commented Feb 28, 2024

And we are using gcc 10 https://packages.debian.org/bullseye/gcc in our build image

@vadim2404
Copy link
Contributor Author

I copied these warnings from CI

@skyzh
Copy link
Member

skyzh commented Feb 29, 2024

Yep, it's specific to gcc 10 and some combination of compile flags. I'm extracting those info from CI and fixing them.

Also -Wall generates way more warnings than CI. In the future we should enable that, but for now I'll just fix the ones reported in CI.

@skyzh
Copy link
Member

skyzh commented Mar 4, 2024

Fixed -Wmissing-prototypes first and looking into other types of warnings + treating warnings as errors in CI in the future

skyzh added a commit that referenced this issue Mar 5, 2024
## Problem

ref #6188

## Summary of changes

This pull request fixes `-Wmissing-prototypes` for the neon extension.
Note that (1) the gcc version in CI and macOS is different, therefore
some of the warning does not get reported when developing the neon
extension locally. (2) the CI env variable `COPT = -Werror` does not get
passed into the docker build process, therefore warnings are not treated
as errors on CI.


https://github.com/neondatabase/neon/blob/e62baa97041e10ce45772b3724e24e679a650d69/.github/workflows/build_and_test.yml#L22

There will be follow-up pull requests on solving other warnings. By the
way, I did not figure out the default compile parameters in the CI env,
and therefore this pull request is tested by manually adding
`-Wmissing-prototypes` into the `COPT`.

Signed-off-by: Alex Chi Z <chi@neon.tech>
@andreasscherbaum
Copy link
Contributor

Newer versions of Ubuntu (GitHub Actions, local Docker on Mac) don't produce this.

@skyzh
Copy link
Member

skyzh commented Mar 7, 2024

decided not to fix -Wdeclaration-after-statement as it is unlikely to cause any runtime errors and fixing it makes the code harder to read (in my opinion)

skyzh added a commit that referenced this issue Mar 11, 2024
proceeding #7010, close
#6188

## Summary of changes

This pull request (should) fix all warnings except
`-Wdeclaration-after-statement` in the neon extension compilation.

---------

Signed-off-by: Alex Chi Z <chi@neon.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/compute Component: compute, excluding postgres itself t/bug Issue Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants